home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_534 / term / source.lzh / termRexx.c < prev    next >
C/C++ Source or Header  |  1991-07-20  |  54KB  |  3,291 lines

  1. /* $Revision Header * Header built automatically - do not edit! *************
  2.  *
  3.  *    (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
  4.  *
  5.  *    Name .....: TermRexx.c
  6.  *    Created ..: Monday 21-Jan-91 20:12
  7.  *    Revision .: 2
  8.  *
  9.  *    Date            Author          Comment
  10.  *    =========       ========        ====================
  11.  *    24-Mar-91       Olsen           Added some more commands.
  12.  *    26-Jan-91       Olsen           Added asynchronous RexxMsg parsing.
  13.  *    21-Jan-91       Olsen           Created this file!
  14.  *
  15.  * $Revision Header ********************************************************/
  16.  
  17. #include "TermGlobal.h"
  18.  
  19.     /* This module contains the ARexx support code I had adapted some
  20.      * time ago for rexxhost.library.
  21.      */
  22.  
  23. struct RexxMsg    *CreateRexxMsg(struct MsgPort *,STRPTR,STRPTR);
  24. VOID         DeleteRexxMsg(struct RexxMsg *);
  25. STRPTR         CreateArgstring(STRPTR,LONG);
  26. VOID         DeleteArgstring(STRPTR);
  27.  
  28. #pragma libcall RexxSysBase CreateArgstring 7e 802
  29. #pragma libcall RexxSysBase DeleteArgstring 84 801
  30. #pragma libcall RexxSysBase CreateRexxMsg 90 9803
  31. #pragma libcall RexxSysBase DeleteRexxMsg 96 801
  32.  
  33.     /* The rexx server commands are contained in lists in which
  34.      * each command name and the approriate routine is
  35.      * stored. The following three structure definitions
  36.      * are required to set up the list properly.
  37.      */
  38.  
  39. struct QueryStruct
  40. {
  41.     UBYTE    *String;
  42.     UBYTE *    (*Routine)(VOID);
  43. };
  44.  
  45. struct ASyncCommandStruct
  46. {
  47.     UBYTE    *String;
  48.     VOID    (*Routine)(VOID);
  49. };
  50.  
  51. struct CommandStruct
  52. {
  53.     UBYTE    *String;
  54.     UBYTE *    (*Routine)(UBYTE *);
  55. };
  56.  
  57.     /* Global rexx output buffer. */
  58.  
  59. STATIC UBYTE RexxTextBuffer[256];
  60.  
  61.     /* This structure defines a relation between a time unit
  62.      * (microseconds, seconds, minutes) and a string key.
  63.      */
  64.  
  65. struct TimeRel
  66. {
  67.     UBYTE    *Key;
  68.     LONG     Multi;
  69. };
  70.  
  71.     /* Relations between qualifying keywords and time multipliers. */
  72.  
  73. #define NUMTIMEREL 9
  74.  
  75. STATIC struct TimeRel TimeRelations[NUMTIMEREL] =
  76. {
  77.     "MIC",        1,
  78.     "SEC",        MILLION,
  79.     "MIN",        MILLION * 60,
  80.  
  81.     "MICROSECONDS",    1,
  82.     "SECONDS",    MILLION,
  83.     "MINUTES",    MILLION * 60,
  84.  
  85.     "MICROS",    1,
  86.     "SECS",        MILLION,
  87.     "MINS",        MILLION * 60
  88. };
  89.  
  90.     /* Asynchronous commands which can be executed by the
  91.      * rexx server process itself and do not require the
  92.      * term main process to take any action.
  93.      */
  94.  
  95. #define NUMASYNCS 9
  96.  
  97. STATIC struct ASyncCommandStruct ASyncCommands[NUMASYNCS] =
  98. {
  99.     "TERM2FRONT",        (APTR)Term2Front,
  100.     "DEFAULT2FRONT",    (APTR)BumpDefault,
  101.     "WB2FRONT",        (APTR)WBenchToFront,
  102.     "REXX2FRONT",        (APTR)Rexx2Front,
  103.     "DISPLAY2FRONT",    (APTR)Display2Front,
  104.     "CLOSEDISPLAY",        (APTR)CloseDisplay,
  105.     "CLEARDISPLAY",        (APTR)ClearBuffer,
  106.     "CLEARDOWNLOADLIST",    (APTR)ClearDownloadObjects,
  107.     "QUIETEXIT",        (APTR)QuietExit
  108. };
  109.  
  110.     /* Query commands which return miscellaneous system
  111.      * information (these routines are handled asynchronously
  112.      * as well).
  113.      */
  114.  
  115. #define NUMQUERIES 73
  116.  
  117. STATIC struct QueryStruct QueryCommands[NUMQUERIES] =
  118. {
  119.     "BAUDRATE",        (APTR)QueryBaud,
  120.     "BITSPERCHAR",        (APTR)QueryDataBits,
  121.     "PARITY",        (APTR)QueryParity,
  122.     "STOPBITS",        (APTR)QueryStopBits,
  123.     "HANDSHAKING",        (APTR)QueryHandshaking,
  124.     "DUPLEX",        (APTR)QueryDuplex,
  125.     "HIGHSPEED",        (APTR)QueryHighspeed,
  126.     "BREAKLENGTH",        (APTR)QueryBreakLength,
  127.     "SERIALDEVICE",        (APTR)QuerySerialDevice,
  128.     "UNITNUMBER",        (APTR)QueryUnitNumber,
  129.     "MODEMINIT",        (APTR)QueryModemInit,
  130.     "MODEMEXIT",        (APTR)QueryModemExit,
  131.     "DIALPREFIX",        (APTR)QueryDialPrefix,
  132.     "REDIALDELAY",        (APTR)QueryRedialDelay,
  133.     "DIALRETRIES",        (APTR)QueryDialRetries,
  134.     "DIALTIMEOUT",        (APTR)QueryDialTimeout,
  135.     "CONNECTAUTOBAUD",    (APTR)QueryConnectAutoBaud,
  136.     "NOCARRIER",        (APTR)QueryNoCarrier,
  137.     "CONNECT",        (APTR)QueryConnect,
  138.     "VOICE",        (APTR)QueryVoice,
  139.     "RING",            (APTR)QueryRing,
  140.     "BUSY",            (APTR)QueryBusy,
  141.     "PROTOCOL",        (APTR)QueryProtocol,
  142.     "PROTOCOLOPTIONS",    (APTR)QueryProtocolOptions,
  143.     "MACROFILE",        (APTR)QueryMacroFile,
  144.     "DISPLAYMODE",        (APTR)QueryDisplay,
  145.     "PUBLICSCREEN",        (APTR)QueryPublicScreen,
  146.     "SHANGHAI",        (APTR)QueryShanghai,
  147.     "CAPTUREFILTER",    (APTR)QueryCaptureFilter,
  148.     "DSBACKSPACE",        (APTR)QueryDSBackSpace,
  149.     "AUDBELL",        (APTR)QueryAudBell,
  150.     "VISBELL",        (APTR)QueryVisBell,
  151.     "EIGHTYCOLUMNS",    (APTR)QueryEightyColumns,
  152.     "SENDCR",        (APTR)QuerySendCR,
  153.     "SENDLF",        (APTR)QuerySendLF,
  154.     "COLOURMODE",        (APTR)QueryColourMode,
  155.     "COLORMODE",        (APTR)QueryColourMode,
  156.     "EMULATION",        (APTR)QueryEmulation,
  157.     "FONT",            (APTR)QueryFont,
  158.     "STATUS",        (APTR)QueryStatus,
  159.     "SERIAL",        (APTR)QuerySerial,
  160.     "STARTUP",        (APTR)QueryStartup,
  161.     "REQUESTERS",        (APTR)QueryRequesters,
  162.     "TIMEOUT",        (APTR)QueryTimeout,
  163.     "LINE",            (APTR)QueryLine,
  164.     "COLUMNS",        (APTR)QueryColumns,
  165.     "LINES",        (APTR)QueryLines,
  166.     "CURSOR",        (APTR)QueryCursor,
  167.  
  168.     /* Added in revision 1.6 */
  169.  
  170.     "MODEMHANGUP",        (APTR)QueryModemHangup,
  171.     "AUTOCAPTURE",        (APTR)QueryAutoCapture,
  172.     "LOGACTIONS",        (APTR)QueryLogActions,
  173.     "BLINKING",        (APTR)QueryBlinking,
  174.     "CURSORMODE",        (APTR)QueryCursorMode,
  175.     "FONTSCALE",        (APTR)QueryFontScale,
  176.     "SMOOTHSCROLL",        (APTR)QueryJumpScroll,
  177.     "CHARACTERWRAP",    (APTR)QueryCharacterWrap,
  178.     "CURSORWRAP",        (APTR)QueryCursorWrap,
  179.     "NEWLINEMODE",        (APTR)QueryNewLine,
  180.     "INSERTMODE",        (APTR)QueryInsert,
  181.     "NUMERICMODE",        (APTR)QueryNumeric,
  182.     "DEFAULTSTORE",        (APTR)QueryDefaultStore,
  183.     "TUPLOADPATH",        (APTR)QueryTUploadPath,
  184.     "TDOWNLOADPATH",    (APTR)QueryTDownloadPath,
  185.     "AUPLOADPATH",        (APTR)QueryAUploadPath,
  186.     "ADOWNLOADPATH",    (APTR)QueryADownloadPath,
  187.     "BUPLOADPATH",        (APTR)QueryBUploadPath,
  188.     "BDOWNLOADPATH",    (APTR)QueryBDownloadPath,
  189.     "CAPTUREPATH",        (APTR)QueryCapturePath,
  190.     "LOGFILE",        (APTR)QueryLogFile,
  191.     "EDITOR",        (APTR)QueryEditor,
  192.     "BEEPSOUND",        (APTR)QueryBeepSound,
  193.     "CAPTURESTATE",        (APTR)QueryCaptureState,
  194.     "DOWNLOADS",        (APTR)QueryDownloads
  195. };
  196.  
  197.     /* Any options which are to be set using the `SET' command
  198.      * are stored in the following list (these commands are
  199.      * handled synchronously).
  200.      */
  201.  
  202. #define NUMSETS        65
  203.  
  204.     /* How many set commands require more parameters? */
  205.  
  206. #define SETMOREPARAMS    6
  207.  
  208. STATIC struct CommandStruct SetCommands[NUMSETS] =
  209. {
  210.     /* The first five commands require more than
  211.      * one calling parameter and are handled
  212.      * differently (as compared to the other
  213.      * set commands).
  214.      */
  215.  
  216.     "MACRO",        (APTR)RexxSetMacro,
  217.     "COLOUR",        (APTR)RexxSetColour,
  218.     "COLOR",        (APTR)RexxSetColour,
  219.     "SCREEN",        (APTR)RexxSetScreen,
  220.     "BELL",            (APTR)RexxSetBell,
  221.     "TIMEOUT",        (APTR)RexxSetTimeout,
  222.  
  223.     "BAUDRATE",        (APTR)RexxSetBaud,
  224.     "BITSPERCHAR",        (APTR)RexxSetDataBits,
  225.     "PARITY",        (APTR)RexxSetParity,
  226.     "STOPBITS",        (APTR)RexxSetStopBits,
  227.     "HANDSHAKING",        (APTR)RexxSetHandshaking,
  228.     "DUPLEX",        (APTR)RexxSetDuplex,
  229.     "HIGHSPEED",        (APTR)RexxSetHighSpeed,
  230.     "BREAKLENGTH",        (APTR)RexxSetBreakLength,
  231.     "SERIALDEVICE",        (APTR)RexxSetSerialDevice,
  232.     "UNITNUMBER",        (APTR)RexxSetUnitNumber,
  233.     "MODEMINIT",        (APTR)RexxSetModemInit,
  234.     "MODEMEXIT",        (APTR)RexxSetModemExit,
  235.     "DIALPREFIX",        (APTR)RexxSetDialPrefix,
  236.     "REDIALDELAY",        (APTR)RexxSetRedialDelay,
  237.     "DIALRETRIES",        (APTR)RexxSetDialRetries,
  238.     "DIALTIMEOUT",        (APTR)RexxSetDialTimeout,
  239.     "CONNECTAUTOBAUD",    (APTR)RexxSetConnectAutoBaud,
  240.     "NOCARRIER",        (APTR)RexxSetNoCarrier,
  241.     "CONNECT",        (APTR)RexxSetConnect,
  242.     "VOICE",        (APTR)RexxSetVoice,
  243.     "RING",            (APTR)RexxSetRing,
  244.     "BUSY",            (APTR)RexxSetBusy,
  245.     "SCREENMODE",        (APTR)RexxSetScreenMode,
  246.     "FILTER",        (APTR)RexxSetFilter,
  247.     "BACKSPACE",        (APTR)RexxSetBackspace,
  248.     "CR",            (APTR)RexxSetCR,
  249.     "LF",            (APTR)RexxSetLF,
  250.     "EIGHTYCOLUMNS",    (APTR)RexxSet80Columns,
  251.     "COLOURMODE",        (APTR)RexxSetColourMode,
  252.     "COLORMODE",        (APTR)RexxSetColourMode,
  253.     "EMULATION",        (APTR)RexxSetEmulation,
  254.     "FONT",            (APTR)RexxSetFont,
  255.     "STARTUP",        (APTR)RexxSetStartup,
  256.     "PROTOCOL",        (APTR)RexxSetProtocol,
  257.     "PROTOCOLOPTIONS",    (APTR)RexxSetProtocolOptions,
  258.     "REQUESTERS",        (APTR)RexxSetRequesters,
  259.     "SERIAL",        (APTR)RexxSetSerial,
  260.  
  261.     /* Added in revision 1.6 */
  262.  
  263.     "MODEMHANGUP",        (APTR)RexxSetModemHangup,
  264.     "AUTOCAPTURE",        (APTR)RexxSetAutoCapture,
  265.     "LOGACTIONS",        (APTR)RexxSetLogActions,
  266.     "BLINKING",        (APTR)RexxSetBlinking,
  267.     "CURSORMODE",        (APTR)RexxSetCursorMode,
  268.     "FONTSCALE",        (APTR)RexxSetFontScale,
  269.     "SMOOTHSCROLL",        (APTR)RexxSetJumpScroll,
  270.     "CHARACTERWRAP",    (APTR)RexxSetCharacterWrap,
  271.     "CURSORWRAP",        (APTR)RexxSetCursorWrap,
  272.     "NEWLINEMODE",        (APTR)RexxSetNewLine,
  273.     "INSERTMODE",        (APTR)RexxSetInsert,
  274.     "NUMERICMODE",        (APTR)RexxSetNumeric,
  275.     "DEFAULTSTORE",        (APTR)RexxSetDefaultStore,
  276.     "TUPLOADPATH",        (APTR)RexxSetTUploadPath,
  277.     "TDOWNLOADPATH",    (APTR)RexxSetTDownloadPath,
  278.     "AUPLOADPATH",        (APTR)RexxSetAUploadPath,
  279.     "ADOWNLOADPATH",    (APTR)RexxSetADownloadPath,
  280.     "BUPLOADPATH",        (APTR)RexxSetBUploadPath,
  281.     "BDOWNLOADPATH",    (APTR)RexxSetBDownloadPath,
  282.     "CAPTUREPATH",        (APTR)RexxSetCapturePath,
  283.     "LOGFILE",        (APTR)RexxSetLogFile,
  284.     "EDITOR",        (APTR)RexxSetEditor
  285. };
  286.  
  287.     /* The following list contains only synchronous commands
  288.      * the rexx server passes to the term main process.
  289.      */
  290.  
  291. #define NUMREXX        30
  292.  
  293.     /* How many commands require more parameters. */
  294.  
  295. #define REXXMOREPARAMS    7
  296.  
  297. struct CommandStruct RexxCommands[NUMREXX] =
  298. {
  299.     /* The first five commands require more than
  300.      * one calling parameter.
  301.      */
  302.  
  303.     "BUFFER",        (APTR)RexxBuffer,
  304.     "CAPTURE",        (APTR)RexxCapture,
  305.     "CONFIG",        (APTR)RexxConfig,
  306.     "MACROS",        (APTR)RexxMacros,
  307.     "PHONE",        (APTR)RexxPhone,
  308.     "DELAY",        (APTR)RexxDelay,
  309.     "WAITSTRING",        (APTR)RexxWaitString,
  310.  
  311.     "PRINTER",        (APTR)RexxPrinter,
  312.     "BEEP",            (APTR)DoSomeBeep,
  313.     "BREAK",        (APTR)RexxBreak,
  314.     "BUPLOAD",        (APTR)RexxBUpload,
  315.     "BDOWNLOAD",        (APTR)RexxBDownload,
  316.     "CLEARSCREEN",        (APTR)RexxClearScreen,
  317.     "COMMAND",        (APTR)RexxCommand,
  318.     "DIAL",            (APTR)RexxDial,
  319.     "GETSTRING",        (APTR)RexxGetString,
  320.     "HANGUP",        (APTR)RexxHangUp,
  321.     "INPUT",        (APTR)RexxInput,
  322.     "MESSAGE",        (APTR)RexxMessage,
  323.     "RESETSTYLES",        (APTR)RexxResetStyles,
  324.     "SAVEILBM",        (APTR)RexxSaveILBM,
  325.     "TUPLOAD",        (APTR)RexxTUpload,
  326.     "TDOWNLOAD",        (APTR)RexxTDownload,
  327.     "WRITE",        (APTR)RexxWrite,
  328.     "PUTCLIP",        (APTR)RexxPutClip,
  329.     "GETCLIP",        (APTR)RexxGetClip,
  330.  
  331.     /* Added in revision 1.6 */
  332.  
  333.     "FIRSTDOWNLOAD",    (APTR)RexxFirstDownload,
  334.     "NEXTDOWNLOAD",        (APTR)RexxNextDownload,
  335.     "LASTDOWNLOAD",        (APTR)RexxLastDownload,
  336.  
  337.     /* Added in revision 1.8a */
  338.  
  339.     "TONEDIAL",        (APTR)RexxToneDial
  340. };
  341.  
  342.     /* A global error code and a global input timeout. */
  343.  
  344. STATIC LONG RexxRes1,RexxGlobalTimeout;
  345.  
  346.     /* The names of the 16 display mode IDs in abbreviated
  347.      * form.
  348.      */
  349.  
  350. STATIC UBYTE *ConfigDisplayNames[16] =
  351. {
  352.     "HIRES",
  353.     "HIRESLACE",
  354.     "SUPERHIRES",
  355.     "SUPERHIRESLACE",
  356.     "PRODUCT",
  357.     "PRODUCTLACE",
  358.  
  359.     "PALHIRES",
  360.     "PALHIRESLACE",
  361.     "PALSUPERHIRES",
  362.     "PALSUPERHIRESLACE",
  363.  
  364.     "NTSCHIRES",
  365.     "NTSCHIRESLACE",
  366.     "NTSCSUPERHIRES",
  367.     "NTSCSUPERHIRESLACE",
  368.  
  369.     "A2024TENHZ",
  370.     "A2024FIFTEENHZ"
  371. };
  372.  
  373.     /* The global duplex modes in abbreviated form. */
  374.  
  375. STATIC UBYTE *ConfigDuplex[2] =
  376. {
  377.     "FULL",
  378.     "HALF"
  379. };
  380.  
  381.     /* The global handshake modes in abbreviated form. */
  382.  
  383. STATIC UBYTE *ConfigHandshaking[3] =
  384. {
  385.     "XONOFF",
  386.     "RTSCTS",
  387.     "NONE"
  388. };
  389.  
  390.     /* The global fonts in abbreviated form. */
  391.  
  392. STATIC UBYTE *ConfigFont[2] =
  393. {
  394.     "TOPAZ",
  395.     "IBM"
  396. };
  397.  
  398.     /* The global colour modes in abbreviated form. */
  399.  
  400. STATIC UBYTE *ConfigColour[4] =
  401. {
  402.     "AMIGA",
  403.     "EIGHT",
  404.     "SIXTEEN",
  405.     "MONO"
  406. };
  407.  
  408.     /* The emulation types in abbreviated form. */
  409.  
  410. STATIC UBYTE *ConfigEmulation[3] =
  411. {
  412.     "ANSIVT",
  413.     "ATOMIC",
  414.     "TTY"
  415. };
  416.  
  417.     /* The global parity settings in abbreviated form. */
  418.  
  419. STATIC UBYTE *ConfigParity[5] =
  420. {
  421.     "NONE",
  422.     "EVEN",
  423.     "ODD",
  424.     "MARK",
  425.     "SPACE"
  426. };
  427.  
  428.     /* The global term status modes in abbreviated form. */
  429.  
  430. STATIC UBYTE *ConfigStatus[7] =
  431. {
  432.     "READY",
  433.     "HOLDING",
  434.     "DIALING",
  435.     "UPLOAD",
  436.     "DOWNLOAD",
  437.     "BREAKING",
  438.     "HANGUP"
  439. };
  440.  
  441.     /* Two boolean identifiers. */
  442.  
  443. STATIC UBYTE *Booleans[2] =
  444. {
  445.     "OFF",
  446.     "ON"
  447. };
  448.  
  449. STATIC UBYTE *KeyModes[2] =
  450. {
  451.     "STANDARD",
  452.     "APPLICATION"
  453. };
  454.  
  455. STATIC UBYTE *FontSizes[5] =
  456. {
  457.     "NORMAL",
  458.     "HIGHTOP",
  459.     "HIGHBOTTOM",
  460.     "WIDE",
  461.     "HALF"
  462. };
  463.  
  464. STATIC UBYTE *Qualifiers[4] =
  465. {
  466.     "NONE",
  467.     "SHIFT",
  468.     "ALTERNATE",
  469.     "CONTROL"
  470. };
  471.  
  472.     /* SendRexxCommand():
  473.      *
  474.      *    Post a command to an ARexx port.
  475.      */
  476.  
  477. BYTE
  478. SendRexxCommand(struct MsgPort *HostPort,STRPTR CommandString,STRPTR FileExtension,STRPTR HostName)
  479. {
  480.     struct MsgPort    *RexxPort = (struct MsgPort *)FindPort(RXSDIR);
  481.     struct RexxMsg    *HostMessage;
  482.  
  483.     if(RexxPort)
  484.     {
  485.         if(!HostName)
  486.             HostName = (STRPTR)"";
  487.  
  488.         if(!FileExtension)
  489.             FileExtension = (STRPTR)"";
  490.  
  491.         if(HostMessage = CreateRexxMsg((struct MsgPort *)HostPort,FileExtension,HostName))
  492.         {
  493.             if(HostMessage -> rm_Args[0] = CreateArgstring(CommandString,strlen(CommandString)))
  494.             {
  495.                 HostMessage -> rm_Action = RXCOMM;
  496.  
  497.                 PutMsg(RexxPort,HostMessage);
  498.  
  499.                 return(TRUE);
  500.             }
  501.  
  502.             DeleteRexxMsg(HostMessage);
  503.         }
  504.  
  505.         MyEasyRequest(Window,"term has a problem:\nCouldn't send rexx message!","Continue");
  506.  
  507.         return(FALSE);
  508.     }
  509.     else
  510.         MyEasyRequest(Window,"term has a problem:\nThe ARexx server isn't running!","Continue");
  511. }
  512.  
  513.     /* FreeRexxCommand(struct RexxMsg *RexxMessage):
  514.      *
  515.      *    Free the contents of a RexxMsg.
  516.      */
  517.  
  518. VOID
  519. FreeRexxCommand(struct RexxMsg *RexxMessage)
  520. {
  521.     if(RexxMessage -> rm_Args[0])
  522.         DeleteArgstring(RexxMessage -> rm_Args[0]);
  523.  
  524.     DeleteRexxMsg(RexxMessage);
  525. }
  526.  
  527.     /* ReplyRexxCommand():
  528.      *
  529.      *    Reply a command request the rexx server - or someone else -
  530.      *    has passed to us.
  531.      */
  532.  
  533. VOID
  534. ReplyRexxCommand(struct RexxMsg *RexxMessage,LONG Primary,LONG Secondary,STRPTR Result)
  535. {
  536.     if(Secondary == NULL && (RexxMessage -> rm_Action & RXFF_RESULT))
  537.     {
  538.         if(Result)
  539.         {
  540.             if(Result[0])
  541.                 Secondary = (LONG)CreateArgstring(Result,strlen(Result));
  542.         }
  543.     }
  544.  
  545.     RexxMessage -> rm_Result1 = Primary;
  546.     RexxMessage -> rm_Result2 = Secondary;
  547.  
  548.     ReplyMsg(RexxMessage);
  549. }
  550.  
  551.     /* IsSpace(UBYTE c):
  552.      *
  553.      *    Return if the character passed to this routine is some
  554.      *    kind of blank space.
  555.      */
  556.  
  557. STATIC BYTE
  558. IsSpace(UBYTE c)
  559. {
  560.     if((c >= 13 && c <= 17) || c == 32)
  561.         return(TRUE);
  562.     else
  563.         return(FALSE);
  564. }
  565.  
  566.     /* GetToken():
  567.      *
  568.      *    Parse a string for a token (typically used for
  569.      *    rexx message parsing).
  570.      */
  571.  
  572. STRPTR
  573. GetToken(STRPTR String,LONG *StartChar,STRPTR AuxBuff,LONG MaxLength)
  574. {
  575.     SHORT    i,StrEnd = 0,MaxPos = strlen(String);
  576.     BYTE    Filter = FALSE;
  577.     UBYTE    Brace = 0;
  578.  
  579.     if(MaxPos >= MaxLength + *StartChar)
  580.         MaxPos = MaxLength + *StartChar - 1;
  581.  
  582.     if(*StartChar <= strlen(String) - 1 && String && String[0] && AuxBuff && MaxLength)
  583.     {
  584.         for(i = *StartChar ; i <= MaxPos ; i++)
  585.         {
  586.             if(!Filter)
  587.             {
  588.                 if(!StrEnd && IsSpace(String[i]))
  589.                 {
  590.                     while(IsSpace(String[i]) && i < MaxPos)
  591.                     {
  592.                         i++;
  593.  
  594.                         (*StartChar)++;
  595.                     }
  596.                 }
  597.             }
  598.  
  599.             if((!Filter && IsSpace(String[i])) || String[i] == 0)
  600.             {
  601.                 strncpy(AuxBuff,(String + *StartChar),StrEnd);
  602.                 AuxBuff[StrEnd] = 0;
  603.  
  604.                 (*StartChar) += StrEnd;
  605.  
  606.                 return(AuxBuff);
  607.             }
  608.  
  609.             if(String[i] == '\'' || String[i] == '\"')
  610.             {
  611.                 if(!Filter)
  612.                 {
  613.                     Brace = String[i];
  614.  
  615.                     Filter = TRUE;
  616.                 }
  617.                 else
  618.                 {
  619.                     if(String[i] == Brace)
  620.                         Filter = FALSE;
  621.                 }
  622.             }
  623.  
  624.             StrEnd++;
  625.         }
  626.     }
  627.  
  628.     return(NULL);
  629. }
  630.  
  631.     /* A bunch of single rexx server routines is to follow.
  632.      * Since there are pretty much of subroutines, I didn't
  633.      * necessarily make a comment on any (figure out yourself
  634.      * how they work :-)
  635.      */
  636.  
  637. UBYTE *
  638. QueryBaud()
  639. {
  640.     SPrintf(RexxTextBuffer,"%ld",Config . BaudRate);
  641.  
  642.     return(RexxTextBuffer);
  643. }
  644.  
  645. UBYTE *
  646. QueryDataBits()
  647. {
  648.     SPrintf(RexxTextBuffer,"%ld",Config . BitsPerChar);
  649.  
  650.     return(RexxTextBuffer);
  651. }
  652.  
  653. UBYTE *
  654. QueryParity()
  655. {
  656.     return(ConfigParity[Config . Parity]);
  657. }
  658.  
  659. UBYTE *
  660. QueryStopBits()
  661. {
  662.     SPrintf(RexxTextBuffer,"%ld",Config . StopBits);
  663.  
  664.     return(RexxTextBuffer);
  665. }
  666.  
  667. UBYTE *
  668. QueryHandshaking()
  669. {
  670.     return(ConfigHandshaking[Config . Handshaking]);
  671. }
  672.  
  673. UBYTE *
  674. QueryDuplex()
  675. {
  676.     return(ConfigDuplex[Config . Duplex]);
  677. }
  678.  
  679. UBYTE *
  680. QueryHighspeed()
  681. {
  682.     return(Booleans[Config . HighSpeed]);
  683. }
  684.  
  685. UBYTE *
  686. QueryBreakLength()
  687. {
  688.     SPrintf(RexxTextBuffer,"%ld",Config . BreakLength);
  689.  
  690.     return(RexxTextBuffer);
  691. }
  692.  
  693. UBYTE *
  694. QuerySerialDevice()
  695. {
  696.     return(Config . SerialDevice);
  697. }
  698.  
  699. UBYTE *
  700. QueryUnitNumber()
  701. {
  702.     SPrintf(RexxTextBuffer,"%ld",Config . UnitNumber);
  703.  
  704.     return(RexxTextBuffer);
  705. }
  706.  
  707. UBYTE *
  708. QueryModemInit()
  709. {
  710.     return(Config . ModemInit);
  711. }
  712.  
  713. UBYTE *
  714. QueryModemExit()
  715. {
  716.     return(Config . ModemExit);
  717. }
  718.  
  719. UBYTE *
  720. QueryDialPrefix()
  721. {
  722.     return(Config . DialPrefix);
  723. }
  724.  
  725. UBYTE *
  726. QueryRedialDelay()
  727. {
  728.     SPrintf(RexxTextBuffer,"%ld",Config . RedialDelay);
  729.  
  730.     return(RexxTextBuffer);
  731. }
  732.  
  733. UBYTE *
  734. QueryDialRetries()
  735. {
  736.     SPrintf(RexxTextBuffer,"%ld",Config . DialRetries);
  737.  
  738.     return(RexxTextBuffer);
  739. }
  740.  
  741. UBYTE *
  742. QueryDialTimeout()
  743. {
  744.     SPrintf(RexxTextBuffer,"%ld",Config . DialTimeout);
  745.  
  746.     return(RexxTextBuffer);
  747. }
  748.  
  749. UBYTE *
  750. QueryConnectAutoBaud()
  751. {
  752.     return(Booleans[Config . ConnectAutoBaud]);
  753. }
  754.  
  755. UBYTE *
  756. QueryNoCarrier()
  757. {
  758.     return(Config . NoCarrier);
  759. }
  760.  
  761. UBYTE *
  762. QueryConnect()
  763. {
  764.     return(Config . Connect);
  765. }
  766.  
  767. UBYTE *
  768. QueryVoice()
  769. {
  770.     return(Config . Voice);
  771. }
  772.  
  773. UBYTE *
  774. QueryRing()
  775. {
  776.     return(Config . Ring);
  777. }
  778.  
  779. UBYTE *
  780. QueryBusy()
  781. {
  782.     return(Config . Busy);
  783. }
  784.  
  785. UBYTE *
  786. QueryProtocol()
  787. {
  788.     return(Config . Protocol);
  789. }
  790.  
  791. UBYTE *
  792. QueryProtocolOptions()
  793. {
  794.     return(ProtocolOptsBuffer);
  795. }
  796.  
  797. UBYTE *
  798. QueryMacroFile()
  799. {
  800.     return(Config . MacroFile);
  801. }
  802.  
  803. UBYTE *
  804. QueryDisplay()
  805. {
  806.     SHORT i;
  807.  
  808.     for(i = 0 ; i < 16 ; i++)
  809.         if(Config . DisplayMode == ModeID[i])
  810.             return(ConfigDisplayNames[i]);
  811. }
  812.  
  813. UBYTE *
  814. QueryPublicScreen()
  815. {
  816.     return(Booleans[Config . MakeScreenPublic]);
  817. }
  818.  
  819. UBYTE *
  820. QueryShanghai()
  821. {
  822.     return(Booleans[Config . ShanghaiWindows]);
  823. }
  824.  
  825. UBYTE *
  826. QueryCaptureFilter()
  827. {
  828.     return(Booleans[Config . HighSpeed]);
  829. }
  830.  
  831. UBYTE *
  832. QueryDSBackSpace()
  833. {
  834.     return(Booleans[Config . DestructiveBackspace]);
  835. }
  836.  
  837. UBYTE *
  838. QueryAudBell()
  839. {
  840.     return(Booleans[Config . AudibleBell]);
  841. }
  842.  
  843. UBYTE *
  844. QueryVisBell()
  845. {
  846.     return(Booleans[Config . VisibleBell]);
  847. }
  848.  
  849. UBYTE *
  850. QueryEightyColumns()
  851. {
  852.     return(Booleans[Config . EightyColumns]);
  853. }
  854.  
  855. UBYTE *
  856. QuerySendCR()
  857. {
  858.     switch(Config . SendCR)
  859.     {
  860.         case CR_IGNORE:        return("IGNORE");
  861.         case CR_ASCR:        return("CR");
  862.         case CR_ASCRLF:        return("CRLF");
  863.     }
  864. }
  865.  
  866. UBYTE *
  867. QuerySendLF()
  868. {
  869.     switch(Config . SendLF)
  870.     {
  871.         case LF_IGNORE:        return("IGNORE");
  872.         case LF_ASLF:        return("LF");
  873.         case LF_ASLFCR:        return("LFCR");
  874.     }
  875. }
  876.  
  877. UBYTE *
  878. QueryColourMode()
  879. {
  880.     return(ConfigColour[Config . ColourMode]);
  881. }
  882.  
  883. UBYTE *
  884. QueryEmulation()
  885. {
  886.     return(ConfigEmulation[Config . Emulation]);
  887. }
  888.  
  889. UBYTE *
  890. QueryFont()
  891. {
  892.     return(ConfigFont[Config . Font]);
  893. }
  894.  
  895. UBYTE *
  896. QueryStatus()
  897. {
  898.     return(ConfigStatus[Status]);
  899. }
  900.  
  901. UBYTE *
  902. QuerySerial()
  903. {
  904.     return(Booleans[ReadPort ? 1 : 0]);
  905. }
  906.  
  907. UBYTE *
  908. QueryStartup()
  909. {
  910.     return(Config . StartupMacro);
  911. }
  912.  
  913. UBYTE *
  914. QueryRequesters()
  915. {
  916.     return((LONG)ThisProcess -> pr_WindowPtr == -1 ? Booleans[0] : Booleans[1]);
  917. }
  918.  
  919. UBYTE *
  920. QueryTimeout()
  921. {
  922.     SPrintf(RexxTextBuffer,"%ld",RexxGlobalTimeout);
  923.  
  924.     return(RexxTextBuffer);
  925. }
  926.  
  927. UBYTE *
  928. QueryLine()
  929. {
  930.     return(Booleans[Online]);
  931. }
  932.  
  933. UBYTE *
  934. QueryLines()
  935. {
  936.     SPrintf(RexxTextBuffer,"%ld",LastLine);
  937.  
  938.     return(RexxTextBuffer);
  939. }
  940.  
  941. UBYTE *
  942. QueryColumns()
  943. {
  944.     SPrintf(RexxTextBuffer,"%ld",LastColumn);
  945.  
  946.     return(RexxTextBuffer);
  947. }
  948.  
  949. UBYTE *
  950. QueryCursor()
  951. {
  952.     SPrintf(RexxTextBuffer,"%ld %ld",CursorX,CursorY);
  953.  
  954.     return(RexxTextBuffer);
  955. }
  956.  
  957. UBYTE *
  958. QueryModemHangup()
  959. {
  960.     return(Config . ModemHangup);
  961. }
  962.  
  963. UBYTE *
  964. QueryAutoCapture()
  965. {
  966.     return(Booleans[Config . ConnectAutoCapture]);
  967. }
  968.  
  969. UBYTE *
  970. QueryLogActions()
  971. {
  972.     return(Booleans[Config . LogActions]);
  973. }
  974.  
  975. UBYTE *
  976. QueryBlinking()
  977. {
  978.     return(Booleans[Config . DisableBlinking ^ TRUE]);
  979. }
  980.  
  981. UBYTE *
  982. QueryCursorMode()
  983. {
  984.     return(KeyModes[Config . CursorApp]);
  985. }
  986.  
  987. UBYTE *
  988. QueryFontScale()
  989. {
  990.     return(FontSizes[Config . FontScale]);
  991. }
  992.  
  993. UBYTE *
  994. QueryJumpScroll()
  995. {
  996.     return(Booleans[Config . JumpScroll ^ TRUE]);
  997. }
  998.  
  999. UBYTE *
  1000. QueryCharacterWrap()
  1001. {
  1002.     return(Booleans[Config . AutoWrap]);
  1003. }
  1004.  
  1005. UBYTE *
  1006. QueryCursorWrap()
  1007. {
  1008.     return(Booleans[Config . CursorWrap]);
  1009. }
  1010.  
  1011. UBYTE *
  1012. QueryNewLine()
  1013. {
  1014.     return(Booleans[Config . NewLine]);
  1015. }
  1016.  
  1017. UBYTE *
  1018. QueryInsert()
  1019. {
  1020.     return(Booleans[Config . InsertChar]);
  1021. }
  1022.  
  1023. UBYTE *
  1024. QueryNumeric()
  1025. {
  1026.     return(KeyModes[Config . NumApp]);
  1027. }
  1028.  
  1029. UBYTE *
  1030. QueryDefaultStore()
  1031. {
  1032.     return(Config . DefaultStorage);
  1033. }
  1034.  
  1035. UBYTE *
  1036. QueryTUploadPath()
  1037. {
  1038.     return(Config . TextUploadPath);
  1039. }
  1040.  
  1041. UBYTE *
  1042. QueryTDownloadPath()
  1043. {
  1044.     return(Config . TextDownloadPath);
  1045. }
  1046.  
  1047. UBYTE *
  1048. QueryAUploadPath()
  1049. {
  1050.     return(Config . ASCIIUploadPath);
  1051. }
  1052.  
  1053. UBYTE *
  1054. QueryADownloadPath()
  1055. {
  1056.     return(Config . ASCIIDownloadPath);
  1057. }
  1058.  
  1059. UBYTE *
  1060. QueryBUploadPath()
  1061. {
  1062.     return(Config . BinaryUploadPath);
  1063. }
  1064.  
  1065. UBYTE *
  1066. QueryBDownloadPath()
  1067. {
  1068.     return(Config . BinaryDownloadPath);
  1069. }
  1070.  
  1071. UBYTE *
  1072. QueryCapturePath()
  1073. {
  1074.     return(Config . CapturePath);
  1075. }
  1076.  
  1077. UBYTE *
  1078. QueryLogFile()
  1079. {
  1080.     return(Config . LogFile);
  1081. }
  1082.  
  1083. UBYTE *
  1084. QueryEditor()
  1085. {
  1086.     return(Config . Editor);
  1087. }
  1088.  
  1089. UBYTE *
  1090. QueryBeepSound()
  1091. {
  1092.     return(Config . BeepSound);
  1093. }
  1094.  
  1095. UBYTE *
  1096. QueryCaptureState()
  1097. {
  1098.     RexxTextBuffer[0] = 0;
  1099.  
  1100.     if(PrinterCapture)
  1101.     {
  1102.         strcat(RexxTextBuffer,"PRINTER");
  1103.  
  1104.         if(FileCapture)
  1105.             strcat(RexxTextBuffer," FILE");
  1106.     }
  1107.     else
  1108.     {
  1109.         if(FileCapture)
  1110.             strcat(RexxTextBuffer,"FILE");
  1111.         else
  1112.             strcat(RexxTextBuffer,Booleans[0]);
  1113.     }        
  1114.  
  1115.     return(RexxTextBuffer);
  1116. }
  1117.  
  1118. UBYTE *
  1119. QueryDownloads()
  1120. {
  1121.     SPrintf(RexxTextBuffer,"%ld",DownloadLineCount);
  1122.  
  1123.     return(RexxTextBuffer);
  1124. }
  1125.  
  1126. VOID
  1127. RexxSetBaud(UBYTE *String)
  1128. {
  1129.     LONG Value = atol(String);
  1130.  
  1131.     if(Config . BaudRate != Value)
  1132.     {
  1133.         Config . BaudRate = Value;
  1134.  
  1135.         ResetSerial = TRUE;
  1136.     }
  1137. }
  1138.  
  1139. VOID
  1140. RexxSetDataBits(UBYTE *String)
  1141. {
  1142.     LONG Bits = atol(String);
  1143.  
  1144.     if(Bits == 7 || Bits == 8)
  1145.     {
  1146.         if(Config . BitsPerChar != Bits)
  1147.         {
  1148.             Config . BitsPerChar = Bits;
  1149.  
  1150.             ResetSerial = TRUE;
  1151.         }
  1152.     }
  1153.     else
  1154.         RexxRes1 = RC_ERROR;
  1155. }
  1156.  
  1157. VOID
  1158. RexxSetParity(UBYTE *String)
  1159. {
  1160.     SHORT i;
  1161.  
  1162.     for(i = 0 ; i < 5 ; i++)
  1163.     {
  1164.         if(!StrCmp(String,ConfigParity[i]))
  1165.         {
  1166.             if(Config . Parity != i)
  1167.             {
  1168.                 Config . Parity = i;
  1169.  
  1170.                 ResetSerial = TRUE;
  1171.             }
  1172.  
  1173.             break;
  1174.         }
  1175.     }
  1176. }
  1177.  
  1178. VOID
  1179. RexxSetStopBits(UBYTE *String)
  1180. {
  1181.     LONG Bits = atol(String);
  1182.  
  1183.     if(Bits == 1 || Bits == 2)
  1184.     {
  1185.         if(Config . StopBits != Bits)
  1186.         {
  1187.             Config . StopBits = Bits;
  1188.  
  1189.             ResetSerial = TRUE;
  1190.         }
  1191.     }
  1192.     else
  1193.         RexxRes1 = RC_ERROR;
  1194. }
  1195.  
  1196. VOID
  1197. RexxSetHandshaking(UBYTE *String)
  1198. {
  1199.     SHORT i;
  1200.  
  1201.     for(i = 0 ; i < 3 ; i++)
  1202.     {
  1203.         if(!StrCmp(String,ConfigHandshaking[i]))
  1204.         {
  1205.             if(Config . Handshaking != i)
  1206.             {
  1207.                 Config . Handshaking = i;
  1208.  
  1209.                 ResetSerial = TRUE;
  1210.             }
  1211.  
  1212.             break;
  1213.         }
  1214.     }
  1215. }
  1216.  
  1217. VOID
  1218. RexxSetDuplex(UBYTE *String)
  1219. {
  1220.     SHORT i;
  1221.  
  1222.     for(i = 0 ; i < 2 ; i++)
  1223.     {
  1224.         if(!StrCmp(String,ConfigDuplex[i]))
  1225.         {
  1226.             Config . Duplex = i;
  1227.  
  1228.             break;
  1229.         }
  1230.     }
  1231. }
  1232.  
  1233. VOID
  1234. RexxSetHighSpeed(UBYTE *String)
  1235. {
  1236.     SHORT i;
  1237.  
  1238.     for(i = 0 ; i < 2 ; i++)
  1239.     {
  1240.         if(!StrCmp(String,Booleans[i]))
  1241.         {
  1242.             if(Config . HighSpeed != i)
  1243.             {
  1244.                 Config . HighSpeed = i;
  1245.  
  1246.                 ResetSerial = TRUE;
  1247.             }
  1248.  
  1249.             break;
  1250.         }
  1251.     }
  1252. }
  1253.  
  1254. VOID
  1255. RexxSetBreakLength(UBYTE *String)
  1256. {
  1257.     LONG Value = atol(String);
  1258.  
  1259.     if(Config . BreakLength != Value)
  1260.     {
  1261.         Config . BreakLength = Value;
  1262.  
  1263.         ResetSerial = TRUE;
  1264.     }
  1265. }
  1266.  
  1267. VOID
  1268. RexxSetSerialDevice(UBYTE *String)
  1269. {
  1270.     if(strcmp(Config . SerialDevice,String))
  1271.     {
  1272.         strcpy(Config . SerialDevice,String);
  1273.  
  1274.         ResetSerial = TRUE;
  1275.     }
  1276. }
  1277.  
  1278. VOID
  1279. RexxSetUnitNumber(UBYTE *String)
  1280. {
  1281.     LONG Value = atol(String);
  1282.  
  1283.     if(Config . UnitNumber != Value)
  1284.     {
  1285.         Config . UnitNumber = Value;
  1286.  
  1287.         ResetSerial = TRUE;
  1288.     }
  1289. }
  1290.  
  1291. VOID
  1292. RexxSetModemInit(UBYTE *String)
  1293. {
  1294.     strcpy(Config . ModemInit,String);
  1295. }
  1296.  
  1297. VOID
  1298. RexxSetModemExit(UBYTE *String)
  1299. {
  1300.     strcpy(Config . ModemExit,String);
  1301. }
  1302.  
  1303. VOID
  1304. RexxSetDialPrefix(UBYTE *String)
  1305. {
  1306.     strcpy(Config . DialPrefix,String);
  1307. }
  1308.  
  1309. VOID
  1310. RexxSetRedialDelay(UBYTE *String)
  1311. {
  1312.     Config . RedialDelay = atol(String);
  1313. }
  1314.  
  1315. VOID
  1316. RexxSetDialRetries(UBYTE *String)
  1317. {
  1318.     Config . DialRetries = atol(String);
  1319. }
  1320.  
  1321. VOID
  1322. RexxSetDialTimeout(UBYTE *String)
  1323. {
  1324.     Config . DialTimeout = atol(String);
  1325. }
  1326.  
  1327. VOID
  1328. RexxSetConnectAutoBaud(UBYTE *String)
  1329. {
  1330.     SHORT i;
  1331.  
  1332.     for(i = 0 ; i < 2 ; i++)
  1333.     {
  1334.         if(!StrCmp(String,Booleans[i]))
  1335.         {
  1336.             Config . ConnectAutoBaud = i;
  1337.  
  1338.             break;
  1339.         }
  1340.     }
  1341. }
  1342.  
  1343. VOID
  1344. RexxSetNoCarrier(UBYTE *String)
  1345. {
  1346.     strcpy(Config . NoCarrier,String);
  1347. }
  1348.  
  1349. VOID
  1350. RexxSetConnect(UBYTE *String)
  1351. {
  1352.     strcpy(Config . Connect,String);
  1353. }
  1354.  
  1355. VOID
  1356. RexxSetVoice(UBYTE *String)
  1357. {
  1358.     strcpy(Config . Voice,String);
  1359. }
  1360.  
  1361. VOID
  1362. RexxSetRing(UBYTE *String)
  1363. {
  1364.     strcpy(Config . Ring,String);
  1365. }
  1366.  
  1367. VOID
  1368. RexxSetBusy(UBYTE *String)
  1369. {
  1370.     strcpy(Config . Busy,String);
  1371. }
  1372.  
  1373. VOID
  1374. RexxSetScreenMode(UBYTE *String)
  1375. {
  1376.     SHORT i;
  1377.  
  1378.     for(i = 0 ; i < 16 ; i++)
  1379.     {
  1380.         if(!StrCmp(ConfigDisplayNames[i],String))
  1381.         {
  1382.             if(!ModeNotAvailable(ModeID[i]))
  1383.             {
  1384.                 if(Config . DisplayMode != ModeID[i])
  1385.                 {
  1386.                     BYTE Limited;
  1387.  
  1388.                     if(Config . ColourMode == COLOUR_EIGHT || Config . ColourMode == COLOUR_SIXTEEN)
  1389.                         Limited = TRUE;
  1390.                     else
  1391.                         Limited = FALSE;
  1392.  
  1393.                     if(!Limited && ((ModeID[i] & ~MONITOR_ID_MASK) != HIRES_KEY) && ((ModeID[i] & ~MONITOR_ID_MASK) != HIRESLACE_KEY))
  1394.                     {
  1395.                         Config . DisplayMode = ModeID[i];
  1396.  
  1397.                         ResetDisplay = TRUE;
  1398.                     }
  1399.                 }
  1400.             }
  1401.  
  1402.             break;
  1403.         }
  1404.     }
  1405. }
  1406.  
  1407. VOID
  1408. RexxSetFilter(UBYTE *String)
  1409. {
  1410.     SHORT i;
  1411.  
  1412.     for(i = 0 ; i < 2 ; i++)
  1413.     {
  1414.         if(!StrCmp(String,Booleans[i]))
  1415.         {
  1416.             Config . CaptureFilter = i;
  1417.  
  1418.             break;
  1419.         }
  1420.     }
  1421. }
  1422.  
  1423. VOID
  1424. RexxSetBackspace(UBYTE *String)
  1425. {
  1426.     SHORT i;
  1427.  
  1428.     for(i = 0 ; i < 2 ; i++)
  1429.     {
  1430.         if(!StrCmp(String,Booleans[i]))
  1431.         {
  1432.             Config . DestructiveBackspace = i;
  1433.  
  1434.             break;
  1435.         }
  1436.     }
  1437. }
  1438.  
  1439. VOID
  1440. RexxSetCR(UBYTE *String)
  1441. {
  1442.     if(!StrCmp(String,"IGNORE"))
  1443.         Config . SendCR = CR_IGNORE;
  1444.  
  1445.     if(!StrCmp(String,"CR"))
  1446.         Config . SendCR = CR_ASCR;
  1447.  
  1448.     if(!StrCmp(String,"CRLF"))
  1449.         Config . SendCR = CR_ASCRLF;
  1450. }
  1451.  
  1452. VOID
  1453. RexxSetLF(UBYTE *String)
  1454. {
  1455.     if(!StrCmp(String,"IGNORE"))
  1456.         Config . SendLF = LF_IGNORE;
  1457.  
  1458.     if(!StrCmp(String,"LF"))
  1459.         Config . SendLF = LF_ASLF;
  1460.  
  1461.     if(!StrCmp(String,"LFCR"))
  1462.         Config . SendLF = LF_ASLFCR;
  1463. }
  1464.  
  1465. VOID
  1466. RexxSet80Columns(UBYTE *String)
  1467. {
  1468.     SHORT i;
  1469.  
  1470.     for(i = 0 ; i < 2 ; i++)
  1471.     {
  1472.         if(!StrCmp(String,Booleans[i]))
  1473.         {
  1474.             Config . EightyColumns = i;
  1475.  
  1476.             ConfigSetup();
  1477.  
  1478.             break;
  1479.         }
  1480.     }
  1481. }
  1482.  
  1483. VOID
  1484. RexxSetColourMode(UBYTE *String)
  1485. {
  1486.     SHORT i;
  1487.  
  1488.     for(i = 0 ; i < 4 ; i++)
  1489.     {
  1490.         if(!StrCmp(ConfigColour[i],String))
  1491.         {
  1492.             if(i != Config . ColourMode)
  1493.             {
  1494.                 BYTE Limited;
  1495.  
  1496.                 switch(Config . DisplayMode & ~MONITOR_ID_MASK)
  1497.                 {
  1498.                     case HIRES_KEY:
  1499.                     case HIRESLACE_KEY:    Limited = FALSE;
  1500.                                 break;
  1501.  
  1502.                     default:        Limited = TRUE;
  1503.                                 break;
  1504.                 }
  1505.  
  1506.                 if(Config . Emulation == EMULATION_ATOMIC && i > COLOUR_AMIGA && i < COLOUR_MONO)
  1507.                     Config . Emulation = EMULATION_ANSIVT100;
  1508.  
  1509.                 if(Limited && i != COLOUR_AMIGA && i != COLOUR_MONO)
  1510.                 {
  1511.                     if(Config . DisplayMode & LACE)
  1512.                         Config . DisplayMode = DEFAULT_MONITOR_ID|HIRESLACE_KEY;
  1513.                     else
  1514.                         Config . DisplayMode = DEFAULT_MONITOR_ID|HIRES_KEY;
  1515.                 }
  1516.  
  1517.                 Config . ColourMode = i;
  1518.  
  1519.                 ResetDisplay = TRUE;
  1520.             }
  1521.  
  1522.             break;
  1523.         }
  1524.     }
  1525. }
  1526.  
  1527. VOID
  1528. RexxSetEmulation(UBYTE *String)
  1529. {
  1530.     SHORT i;
  1531.  
  1532.     for(i = 0 ; i < 3 ; i++)
  1533.     {
  1534.         if(!StrCmp(String,ConfigEmulation[i]))
  1535.         {
  1536.             if(Config . Emulation != i)
  1537.             {
  1538.                 Config . Emulation = i;
  1539.  
  1540.                 ResetDisplay = TRUE;
  1541.             }
  1542.  
  1543.             break;
  1544.         }
  1545.     }
  1546. }
  1547.  
  1548. VOID
  1549. RexxSetStartup(UBYTE *String)
  1550. {
  1551.     strcpy(Config . StartupMacro,String);
  1552. }
  1553.  
  1554. VOID
  1555. RexxSetFont(UBYTE *String)
  1556. {
  1557.     SHORT i;
  1558.  
  1559.     for(i = 0 ; i < 2 ; i++)
  1560.     {
  1561.         if(!StrCmp(String,ConfigFont[i]))
  1562.         {
  1563.             if(Config . Font != i)
  1564.             {
  1565.                 Config . Font = i;
  1566.  
  1567.                 if(Config . Font == FONT_TOPAZ)
  1568.                     SetFont(RPort,Topaz);
  1569.                 else
  1570.                 {
  1571.                     if(IBM)
  1572.                         SetFont(RPort,IBM);
  1573.                 }
  1574.             }
  1575.  
  1576.             break;
  1577.         }
  1578.     }
  1579. }
  1580.  
  1581. VOID
  1582. RexxSetProtocol(UBYTE *String)
  1583. {
  1584.     if(StrCmp(LastXprLibrary,String))
  1585.     {
  1586.         UBYTE Name[80];
  1587.  
  1588.         SHORT i;
  1589.  
  1590.         for(i = 0 ; i < strlen(String) ; i++)
  1591.             Name[i] = ToLower(String[i]);
  1592.  
  1593.         strcpy(LastXprLibrary,Name);
  1594.  
  1595.         strcpy(Config . Protocol,LastXprLibrary);
  1596.  
  1597.         ProtocolSetup();
  1598.     }
  1599. }
  1600.  
  1601. VOID
  1602. RexxSetProtocolOptions(UBYTE *String)
  1603. {
  1604.     if(StrCmp(ProtocolOptsBuffer,String))
  1605.     {
  1606.         strcpy(ProtocolOptsBuffer,String);
  1607.  
  1608.         XprIO -> xpr_filename = ProtocolOptsBuffer;
  1609.  
  1610.         TransferBits = XProtocolSetup(XprIO);
  1611.  
  1612.         if(!(TransferBits & XPRS_SUCCESS))
  1613.         {
  1614.             CloseLibrary(XProtocolBase);
  1615.  
  1616.             XProtocolBase = NULL;
  1617.  
  1618.             LastXprLibrary[0] = 0;
  1619.  
  1620.             TransferBits = 0;
  1621.  
  1622.             RexxRes1 = RC_ERROR;
  1623.         }
  1624.     }
  1625. }
  1626.  
  1627. VOID
  1628. RexxSetMacro(UBYTE *String)
  1629. {
  1630.     UBYTE Arg1[40],Arg2[40],Arg3[256];
  1631.     LONG ArgCount,i,Qualifier = -1;
  1632.  
  1633.     Arg1[0] = Arg2[0] = Arg3[0] = 0;
  1634.     ArgCount = 0;
  1635.  
  1636.     GetToken(String,&ArgCount,Arg1,40);
  1637.     GetToken(String,&ArgCount,Arg2,40);
  1638.     GetToken(String,&ArgCount,Arg3,256);
  1639.  
  1640.     for(i = 0 ; i < 4 ; i++)
  1641.     {
  1642.         if(!StrCmp(Qualifiers[i],Arg1))
  1643.         {
  1644.             Qualifier = i;
  1645.             break;
  1646.         }
  1647.     }
  1648.  
  1649.     if(Qualifier != -1)
  1650.     {
  1651.         if(Arg2[0] >= '0' && Arg2[0] <= '9')
  1652.             strcpy(MacroKeys -> Keys[Qualifier][Arg2[0] - '0'],Arg3);
  1653.         else
  1654.             RexxRes1 = RC_ERROR;
  1655.     }
  1656.     else
  1657.         RexxRes1 = RC_ERROR;
  1658. }
  1659.  
  1660. VOID
  1661. RexxSetColour(UBYTE *String)
  1662. {
  1663.     UBYTE Arg1[20],Arg2[20];
  1664.     LONG ArgCount;
  1665.  
  1666.     Arg1[0] = Arg2[0] = 0;
  1667.     ArgCount = 0;
  1668.  
  1669.     GetToken(String,&ArgCount,Arg1,20);
  1670.     GetToken(String,&ArgCount,Arg2,20);
  1671.  
  1672.     if(Arg1[0] && Arg2[0])
  1673.     {
  1674.         LONG Colour,Value;
  1675.  
  1676.         Colour    = atol(Arg1);
  1677.         Value    = ahtoi(Arg2);
  1678.  
  1679.         if(Colour >= 0 && Colour < (1 << (Config . ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth)))
  1680.         {
  1681.             Config . Colours[Colour] = Value;
  1682.  
  1683.             if(Config . ColourMode == COLOUR_AMIGA && Config . Emulation == EMULATION_ANSIVT100)
  1684.             {
  1685.                 if(Colour == 0)
  1686.                     BlinkColours[3] = Value;
  1687.  
  1688.                 if(Colour != 3)
  1689.                     BlinkColours[Colour] = Value;
  1690.             }
  1691.             else
  1692.             {
  1693.                 if(Colour == 0 && Config . ColourMode == COLOUR_EIGHT && Config . Emulation == EMULATION_ANSIVT100)
  1694.                 {
  1695.                     SHORT i;
  1696.  
  1697.                     for(i = 8 ; i < 16 ; i++)
  1698.                         BlinkColours[i] = Value;
  1699.                 }
  1700.                 else
  1701.                     BlinkColours[Colour] = Value;
  1702.             }
  1703.  
  1704.             LoadRGB4(VPort,&Config . Colours[0],(1 << Screen -> RastPort . BitMap -> Depth));
  1705.         }
  1706.         else
  1707.             RexxRes1 = RC_ERROR;
  1708.     }
  1709.     else
  1710.         RexxRes1 = RC_ERROR;
  1711. }
  1712.  
  1713. VOID
  1714. RexxSetScreen(UBYTE *String)
  1715. {
  1716.     UBYTE Arg1[20],Arg2[20];
  1717.     LONG ArgCount;
  1718.  
  1719.     Arg1[0] = Arg2[0] = 0;
  1720.     ArgCount = 0;
  1721.  
  1722.     GetToken(String,&ArgCount,Arg1,20);
  1723.     GetToken(String,&ArgCount,Arg2,20);
  1724.  
  1725.     Config . MakeScreenPublic    = FALSE;
  1726.     Config . ShanghaiWindows    = FALSE;
  1727.  
  1728.     if(!StrCmp(Arg1,"PUBLIC") || !StrCmp(Arg2,"PUBLIC"))
  1729.         Config . MakeScreenPublic = TRUE;
  1730.  
  1731.     if(!StrCmp(Arg1,"SHANGHAI") || !StrCmp(Arg2,"SHANGHAI"))
  1732.         Config . ShanghaiWindows = TRUE;
  1733.  
  1734.     PubScreenStuff();
  1735. }
  1736.  
  1737. VOID
  1738. RexxSetBell(UBYTE *String)
  1739. {
  1740.     UBYTE Arg1[20],Arg2[20];
  1741.     LONG ArgCount;
  1742.  
  1743.     Arg1[0] = Arg2[0] = 0;
  1744.     ArgCount = 0;
  1745.  
  1746.     GetToken(String,&ArgCount,Arg1,20);
  1747.     GetToken(String,&ArgCount,Arg2,20);
  1748.  
  1749.     Config . AudibleBell    = FALSE;
  1750.     Config . VisibleBell    = FALSE;
  1751.  
  1752.     if(!StrCmp(Arg1,"VISIBLE") || !StrCmp(Arg2,"VISIBLE"))
  1753.         Config . VisibleBell = TRUE;
  1754.  
  1755.     if(!StrCmp(Arg1,"AUDIBLE") || !StrCmp(Arg2,"AUDIBLE"))
  1756.         Config . AudibleBell = TRUE;
  1757. }
  1758.  
  1759. VOID
  1760. RexxSetRequesters(UBYTE *String)
  1761. {
  1762.     SHORT i;
  1763.  
  1764.     for(i = 0 ; i < 2 ; i++)
  1765.     {
  1766.         if(!StrCmp(String,Booleans[i]))
  1767.         {
  1768.             ThisProcess -> pr_WindowPtr = (APTR)(i ? Window : -1);
  1769.  
  1770.             break;
  1771.         }
  1772.     }
  1773. }
  1774.  
  1775. VOID
  1776. RexxSetSerial(UBYTE *String)
  1777. {
  1778.     if(!StrCmp(String,Booleans[0]) && ReadPort)
  1779.         DeleteSerial();
  1780.  
  1781.     if(!StrCmp(String,Booleans[1]) && !ReadPort)
  1782.     {
  1783.         if(!CreateSerial())
  1784.             RexxRes1 = RC_ERROR;
  1785.     }
  1786. }
  1787.  
  1788. VOID
  1789. RexxSetTimeout(UBYTE *String)
  1790. {
  1791.     UBYTE    Arg1[40],Arg2[40];
  1792.     LONG    ArgCount;
  1793.  
  1794.     ULONG    Time = 0;
  1795.     SHORT    i;
  1796.  
  1797.     Arg1[0] = Arg2[0] = 0;
  1798.     ArgCount = 0;
  1799.  
  1800.     GetToken(String,&ArgCount,Arg1,40);
  1801.     GetToken(String,&ArgCount,Arg2,40);
  1802.  
  1803.     for(i = 0 ; i < NUMTIMEREL ; i++)
  1804.     {
  1805.         if(!StrCmp(Arg2,TimeRelations[i] . Key))
  1806.         {
  1807.             Time = atol(String) * TimeRelations[i] . Multi;
  1808.             break;
  1809.         }
  1810.     }
  1811.  
  1812.     if(Time > 0)
  1813.         RexxGlobalTimeout = Time;
  1814.     else
  1815.         RexxRes1 = RC_ERROR;
  1816. }
  1817.  
  1818. VOID
  1819. RexxSetModemHangup(UBYTE *String)
  1820. {
  1821.     strcpy(Config . ModemHangup,String);
  1822. }
  1823.  
  1824. VOID
  1825. RexxSetAutoCapture(UBYTE *String)
  1826. {
  1827.     SHORT i;
  1828.  
  1829.     for(i = 0 ; i < 2 ; i++)
  1830.     {
  1831.         if(!StrCmp(String,Booleans[i]))
  1832.         {
  1833.             Config . ConnectAutoCapture = i;
  1834.             break;
  1835.         }
  1836.     }
  1837. }
  1838.  
  1839. VOID
  1840. RexxSetLogActions(UBYTE *String)
  1841. {
  1842.     SHORT i;
  1843.  
  1844.     for(i = 0 ; i < 2 ; i++)
  1845.     {
  1846.         if(!StrCmp(String,Booleans[i]))
  1847.         {
  1848.             Config . LogActions = i;
  1849.             break;
  1850.         }
  1851.     }
  1852. }
  1853.  
  1854. VOID
  1855. RexxSetBlinking(UBYTE *String)
  1856. {
  1857.     SHORT i;
  1858.  
  1859.     for(i = 0 ; i < 2 ; i++)
  1860.     {
  1861.         if(!StrCmp(String,Booleans[i]))
  1862.         {
  1863.             Config . DisableBlinking = TRUE ^ i;
  1864.             break;
  1865.         }
  1866.     }
  1867. }
  1868.  
  1869. VOID
  1870. RexxSetCursorMode(UBYTE *String)
  1871. {
  1872.     SHORT i;
  1873.  
  1874.     for(i = 0 ; i < 2 ; i++)
  1875.     {
  1876.         if(!StrCmp(String,KeyModes[i]))
  1877.         {
  1878.             Config . CursorApp = i;
  1879.             break;
  1880.         }
  1881.     }
  1882. }
  1883.  
  1884. VOID
  1885. RexxSetFontScale(UBYTE *String)
  1886. {
  1887.     SHORT i;
  1888.  
  1889.     for(i = 0 ; i < 5 ; i++)
  1890.     {
  1891.         if(!StrCmp(String,FontSizes[i]))
  1892.         {
  1893.             if(i != SCALE_HALF && Config . FontScale == SCALE_HALF)
  1894.             {
  1895.                 CursorX >>= 1;
  1896.                 SetCursor();
  1897.  
  1898.                 if(Config . EightyColumns)
  1899.                     LastColumn = 79;
  1900.                 else
  1901.                     LastColumn = (Window -> Width >> 3) - 1;
  1902.             }
  1903.  
  1904.             if(i == SCALE_HALF && Config . FontScale != SCALE_HALF)
  1905.             {
  1906.                 if(Config . EightyColumns)
  1907.                     LastColumn = 131;
  1908.                 else
  1909.                     LastColumn = (Window -> Width >> 2) - 1;
  1910.             }
  1911.  
  1912.             Config . FontScale = i;
  1913.             break;
  1914.         }
  1915.     }
  1916. }
  1917.  
  1918. VOID
  1919. RexxSetJumpScroll(UBYTE *String)
  1920. {
  1921.     SHORT i;
  1922.  
  1923.     for(i = 0 ; i < 2 ; i++)
  1924.     {
  1925.         if(!StrCmp(String,Booleans[i]))
  1926.         {
  1927.             Config . JumpScroll = TRUE ^ i;
  1928.             break;
  1929.         }
  1930.     }
  1931. }
  1932.  
  1933. VOID
  1934. RexxSetCharacterWrap(UBYTE *String)
  1935. {
  1936.     SHORT i;
  1937.  
  1938.     for(i = 0 ; i < 2 ; i++)
  1939.     {
  1940.         if(!StrCmp(String,Booleans[i]))
  1941.         {
  1942.             Config . AutoWrap = i;
  1943.             break;
  1944.         }
  1945.     }
  1946. }
  1947.  
  1948. VOID
  1949. RexxSetCursorWrap(UBYTE *String)
  1950. {
  1951.     SHORT i;
  1952.  
  1953.     for(i = 0 ; i < 2 ; i++)
  1954.     {
  1955.         if(!StrCmp(String,Booleans[i]))
  1956.         {
  1957.             Config . CursorWrap = i;
  1958.             break;
  1959.         }
  1960.     }
  1961. }
  1962.  
  1963. VOID
  1964. RexxSetNewLine(UBYTE *String)
  1965. {
  1966.     SHORT i;
  1967.  
  1968.     for(i = 0 ; i < 2 ; i++)
  1969.     {
  1970.         if(!StrCmp(String,Booleans[i]))
  1971.         {
  1972.             Config . NewLine = i;
  1973.             break;
  1974.         }
  1975.     }
  1976. }
  1977.  
  1978. VOID
  1979. RexxSetInsert(UBYTE *String)
  1980. {
  1981.     SHORT i;
  1982.  
  1983.     for(i = 0 ; i < 2 ; i++)
  1984.     {
  1985.         if(!StrCmp(String,Booleans[i]))
  1986.         {
  1987.             Config . InsertChar = i;
  1988.             break;
  1989.         }
  1990.     }
  1991. }
  1992.  
  1993. VOID
  1994. RexxSetNumeric(UBYTE *String)
  1995. {
  1996.     SHORT i;
  1997.  
  1998.     for(i = 0 ; i < 2 ; i++)
  1999.     {
  2000.         if(!StrCmp(String,KeyModes[i]))
  2001.         {
  2002.             Config . NumApp = i;
  2003.             break;
  2004.         }
  2005.     }
  2006. }
  2007.  
  2008. VOID
  2009. RexxSetDefaultStore(UBYTE *String)
  2010. {
  2011.     strcpy(Config . DefaultStorage,String);
  2012. }
  2013.  
  2014. VOID
  2015. RexxSetTUploadPath(UBYTE *String)
  2016. {
  2017.     strcpy(Config . TextUploadPath,String);
  2018. }
  2019.  
  2020. VOID
  2021. RexxSetTDownloadPath(UBYTE *String)
  2022. {
  2023.     strcpy(Config . TextDownloadPath,String);
  2024. }
  2025.  
  2026. VOID
  2027. RexxSetAUploadPath(UBYTE *String)
  2028. {
  2029.     strcpy(Config . ASCIIUploadPath,String);
  2030. }
  2031.  
  2032. VOID
  2033. RexxSetADownloadPath(UBYTE *String)
  2034. {
  2035.     strcpy(Config . ASCIIDownloadPath,String);
  2036. }
  2037.  
  2038. VOID
  2039. RexxSetBUploadPath(UBYTE *String)
  2040. {
  2041.     strcpy(Config . BinaryUploadPath,String);
  2042. }
  2043.  
  2044. VOID
  2045. RexxSetBDownloadPath(UBYTE *String)
  2046. {
  2047.     strcpy(Config . BinaryDownloadPath,String);
  2048. }
  2049.  
  2050. VOID
  2051. RexxSetCapturePath(UBYTE *String)
  2052. {
  2053.     strcpy(Config . CapturePath,String);
  2054. }
  2055.  
  2056. VOID
  2057. RexxSetLogFile(UBYTE *String)
  2058. {
  2059.     strcpy(Config . LogFile,String);
  2060. }
  2061.  
  2062. VOID
  2063. RexxSetEditor(UBYTE *String)
  2064. {
  2065.     strcpy(Config . Editor,String);
  2066. }
  2067.  
  2068. UBYTE *
  2069. RexxBreak()
  2070. {
  2071.     BYTE OldStatus = Status;
  2072.  
  2073.     if(WriteRequest)
  2074.     {
  2075.         Status = STATUS_BREAKING;
  2076.  
  2077.         WriteRequest -> IOSer . io_Command = SDCMD_BREAK;
  2078.         DoIO(WriteRequest);
  2079.  
  2080.         Status = OldStatus;
  2081.     }
  2082.  
  2083.     return(NULL);
  2084. }
  2085.  
  2086. UBYTE *
  2087. RexxTUpload(UBYTE *String)
  2088. {
  2089.     BinaryTransfer = FALSE;
  2090.  
  2091.     RexxBUpload(String);
  2092.  
  2093.     return(NULL);
  2094. }
  2095.  
  2096. UBYTE *
  2097. RexxTDownload(UBYTE *String)
  2098. {
  2099.     BinaryTransfer = FALSE;
  2100.  
  2101.     RexxBDownload(String);
  2102.  
  2103.     return(NULL);
  2104. }
  2105.  
  2106. UBYTE *
  2107. RexxBDownload(UBYTE *String)
  2108. {
  2109.     BYTE OldStatus = Status;
  2110.  
  2111.     if(XProtocolBase)
  2112.     {
  2113.         if(!(TransferBits & XPRS_NORECREQ))
  2114.             XprIO -> xpr_filename = String;
  2115.  
  2116.         if(TransferPanel(BinaryTransfer ? "Download File(s)" : "Download Text"))
  2117.         {
  2118.             Status = STATUS_DOWNLOAD;
  2119.  
  2120.             FlushSerial();
  2121.  
  2122.             XProtocolReceive(XprIO);
  2123.  
  2124.             Status = OldStatus;
  2125.  
  2126.             if(ReadRequest)
  2127.             {
  2128.                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2129.                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2130.                 ReadRequest -> IOSer . io_Length    = 1;
  2131.  
  2132.                 SendIO(ReadRequest);
  2133.             }
  2134.  
  2135.             DeleteTransferPanel();
  2136.         }
  2137.     }
  2138.  
  2139.     BinaryTransfer = TRUE;
  2140.  
  2141.     return(NULL);
  2142. }
  2143.  
  2144. UBYTE *
  2145. RexxBUpload(UBYTE *String)
  2146. {
  2147.     BYTE OldStatus = Status;
  2148.  
  2149.     if(XProtocolBase)
  2150.     {
  2151.         if(!(TransferBits & XPRS_NOSNDREQ))
  2152.             XprIO -> xpr_filename = String;
  2153.  
  2154.         if(TransferPanel(BinaryTransfer ? "Upload File(s)" : "Upload Text"))
  2155.         {
  2156.             Status = STATUS_UPLOAD;
  2157.  
  2158.             FlushSerial();
  2159.  
  2160.             XProtocolSend(XprIO);
  2161.  
  2162.             Status = OldStatus;
  2163.  
  2164.             DeleteTransferPanel();
  2165.  
  2166.             if(ReadRequest)
  2167.             {
  2168.                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2169.                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2170.                 ReadRequest -> IOSer . io_Length    = 1;
  2171.  
  2172.                 SendIO(ReadRequest);
  2173.             }
  2174.         }
  2175.     }
  2176.  
  2177.     BinaryTransfer = TRUE;
  2178.  
  2179.     return(NULL);
  2180. }
  2181.  
  2182. UBYTE *
  2183. RexxWrite(UBYTE *String)
  2184. {
  2185.     if(String[0])
  2186.         SerWrite(String,strlen(String));
  2187.     else
  2188.         RexxRes1 = RC_ERROR;
  2189.  
  2190.     return(NULL);
  2191. }
  2192.  
  2193. UBYTE *
  2194. RexxResetStyles()
  2195. {
  2196.     Escape = TRUE;
  2197.  
  2198.     ConProcess("\033[m",3);
  2199.  
  2200.     switch(Config . ColourMode)
  2201.     {
  2202.         case COLOUR_EIGHT:    FgPen = 7;
  2203.                     break;
  2204.  
  2205.         case COLOUR_SIXTEEN:    FgPen = 15;
  2206.                     break;
  2207.  
  2208.         case COLOUR_AMIGA:
  2209.         default:        FgPen = 1;
  2210.                     break;
  2211.     }
  2212.  
  2213.     BgPen = 0;
  2214.  
  2215.     if(RPort -> FgPen != FgPen)
  2216.         SetAPen(RPort,FgPen);
  2217.  
  2218.     if(RPort -> BgPen != BgPen)
  2219.         SetBPen(RPort,BgPen);
  2220.  
  2221.     Config . FontScale = SCALE_NORMAL;
  2222.  
  2223.     Escape = FALSE;
  2224.  
  2225.     return(NULL);
  2226. }
  2227.  
  2228. UBYTE *
  2229. RexxClearScreen()
  2230. {
  2231.     Escape = TRUE;
  2232.  
  2233.     ConProcess("\033[2J\033[H",7);
  2234.  
  2235.     Escape = FALSE;
  2236.  
  2237.     return(NULL);
  2238. }
  2239.  
  2240. UBYTE *
  2241. RexxSaveILBM(UBYTE *String)
  2242. {
  2243.     if(!SaveRPort(&Screen -> RastPort,VPort,0,Window -> TopEdge,Window -> Width,Window -> Height,Screen -> Width,Screen -> Height,FALSE,String))
  2244.         RexxRes1 = RC_ERROR;
  2245.  
  2246.     return(NULL);
  2247. }
  2248.  
  2249. UBYTE *
  2250. RexxHangUp()
  2251. {
  2252.     BYTE OldStatus = Status;
  2253.  
  2254.     Status = STATUS_HANGUP;
  2255.  
  2256.     SerialCommand(Config . ModemHangup);
  2257.  
  2258.     Status = OldStatus;
  2259.  
  2260.     Online = FALSE;
  2261.  
  2262.     Password[0] = 0;
  2263.  
  2264.     return(NULL);
  2265. }
  2266.  
  2267. UBYTE *
  2268. RexxGetString(UBYTE *String)
  2269. {
  2270.     RexxTextBuffer[0] = 0;
  2271.  
  2272.     if(xpr_gets(String[0] ? String : "Get String For Rexx",RexxTextBuffer))
  2273.         return(RexxTextBuffer);
  2274.     else
  2275.         return(NULL);
  2276. }
  2277.  
  2278. UBYTE *
  2279. RexxCommand(UBYTE *String)
  2280. {
  2281.     if(String[0])
  2282.         SerialCommand(String);
  2283.     else
  2284.         RexxRes1 = RC_ERROR;
  2285.  
  2286.     return(NULL);
  2287. }
  2288.  
  2289. UBYTE *
  2290. RexxMessage(UBYTE *String)
  2291. {
  2292.     if(String[0])
  2293.         ConProcess(String,strlen(String));
  2294.     else
  2295.         RexxRes1 = RC_ERROR;
  2296.  
  2297.     return(NULL);
  2298. }
  2299.  
  2300. UBYTE *
  2301. RexxPutClip(UBYTE *String)
  2302. {
  2303.     if(String[0])
  2304.         SaveClip(String,strlen(String));
  2305.     else
  2306.         RexxRes1 = RC_ERROR;
  2307.  
  2308.     return(NULL);
  2309. }
  2310.  
  2311. UBYTE *
  2312. RexxGetClip()
  2313. {
  2314.     LONG Size;
  2315.  
  2316.     if(Size = LoadClip(RexxTextBuffer,255))
  2317.     {
  2318.         RexxTextBuffer[Size] = 0;
  2319.  
  2320.         return(RexxTextBuffer);
  2321.     }
  2322.     else
  2323.         return(NULL);
  2324. }
  2325.  
  2326. UBYTE *
  2327. RexxDelay(UBYTE *String)
  2328. {
  2329.     UBYTE    Arg1[40],Arg2[40];
  2330.     LONG    ArgCount;
  2331.  
  2332.     ULONG    Time = 0;
  2333.     SHORT    i;
  2334.  
  2335.     Arg1[0] = Arg2[0] = 0;
  2336.     ArgCount = 0;
  2337.  
  2338.     GetToken(String,&ArgCount,Arg1,40);
  2339.     GetToken(String,&ArgCount,Arg2,40);
  2340.  
  2341.     for(i = 0 ; i < NUMTIMEREL ; i++)
  2342.     {
  2343.         if(!StrCmp(Arg2,TimeRelations[i] . Key))
  2344.         {
  2345.             Time = atol(String) * TimeRelations[i] . Multi;
  2346.             break;
  2347.         }
  2348.     }
  2349.  
  2350.     if(Time)
  2351.     {
  2352.         ULONG SignalSet;
  2353.  
  2354.         TimeRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  2355.         TimeRequest -> tr_time . tv_secs    = Time / MILLION;
  2356.         TimeRequest -> tr_time . tv_micro    = Time % MILLION;
  2357.  
  2358.         SendIO(TimeRequest);
  2359.  
  2360.         SignalSet = Wait(SIGBREAKF_CTRL_D | (1 << TimeRequest -> tr_node . io_Message . mn_ReplyPort -> mp_SigBit));
  2361.  
  2362.         if(SignalSet & SIGBREAKF_CTRL_D)
  2363.         {
  2364.             if(!CheckIO(TimeRequest))
  2365.                 AbortIO(TimeRequest);
  2366.  
  2367.             WaitIO(TimeRequest);
  2368.  
  2369.             return(NULL);
  2370.         }
  2371.  
  2372.         WaitIO(TimeRequest);
  2373.     }
  2374.     else
  2375.         RexxRes1 = RC_ERROR;
  2376.  
  2377.     return(NULL);
  2378. }
  2379.  
  2380. UBYTE *
  2381. RexxDial(UBYTE *String)
  2382. {
  2383.     LONG i;
  2384.  
  2385.     strcpy(RexxTextBuffer,Config . DialPrefix);
  2386.  
  2387.     for(i = 0 ; i < NumPhoneEntries ; i++)
  2388.     {
  2389.         if(!StrCmp(Phonebook[i] -> Name,String))
  2390.         {
  2391.             strcat(RexxTextBuffer,Phonebook[i] -> Number);
  2392.  
  2393.             goto DialIt;
  2394.         }
  2395.     }
  2396.  
  2397.     strcat(RexxTextBuffer,String);
  2398.  
  2399. DialIt:    strcat(RexxTextBuffer,"\\r");
  2400.  
  2401.     SerialCommand(RexxTextBuffer);
  2402.  
  2403.     return(NULL);
  2404. }
  2405.  
  2406. UBYTE *
  2407. RexxInput(UBYTE *String)
  2408. {
  2409.     LONG Length = atol(String);
  2410.  
  2411.     if(Length > 255)
  2412.         Length = 255;
  2413.  
  2414.     FlushSerial();
  2415.  
  2416.     if(Length = xpr_sread(RexxTextBuffer,Length,RexxGlobalTimeout))
  2417.     {
  2418.         RexxTextBuffer[Length] = 0;
  2419.  
  2420.         if(ReadRequest)
  2421.         {
  2422.             ReadRequest -> IOSer . io_Command    = CMD_READ;
  2423.             ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2424.             ReadRequest -> IOSer . io_Length    = 1;
  2425.  
  2426.             SendIO(ReadRequest);
  2427.         }
  2428.  
  2429.         return(RexxTextBuffer);
  2430.     }
  2431.  
  2432.     if(ReadRequest)
  2433.     {
  2434.         ReadRequest -> IOSer . io_Command    = CMD_READ;
  2435.         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2436.         ReadRequest -> IOSer . io_Length    = 1;
  2437.  
  2438.         SendIO(ReadRequest);
  2439.     }
  2440.  
  2441.     return(NULL);
  2442. }
  2443.  
  2444. UBYTE *
  2445. RexxPrinter(UBYTE *String)
  2446. {
  2447.     struct MenuItem *SomeItem;
  2448.  
  2449.     SomeItem = FindThisItem(MEN_CAPTUREPRINTER);
  2450.  
  2451.     if(!StrCmp(String,Booleans[0]) && PrinterCapture)
  2452.     {
  2453.         Close(PrinterCapture);
  2454.  
  2455.         SomeItem -> Flags &= ~CHECKED;
  2456.  
  2457.         PrinterCapture = NULL;
  2458.     }
  2459.  
  2460.     if(!StrCmp(String,Booleans[1]) && !PrinterCapture)
  2461.     {
  2462.         if(PrinterCapture = Open("PRT:",MODE_NEWFILE))
  2463.             SomeItem -> Flags |= CHECKED;
  2464.         else
  2465.         {
  2466.             SomeItem -> Flags &= ~CHECKED;
  2467.             RexxRes1 = RC_ERROR;
  2468.         }
  2469.     }
  2470.  
  2471.     return(NULL);
  2472. }
  2473.  
  2474. UBYTE *
  2475. RexxMacros(UBYTE *String)
  2476. {
  2477.     UBYTE Arg1[40],Arg2[256];
  2478.     LONG ArgCount;
  2479.  
  2480.     Arg1[0] = Arg2[0] = 0;
  2481.     ArgCount = 0;
  2482.  
  2483.     GetToken(String,&ArgCount,Arg1,40);
  2484.     GetToken(String,&ArgCount,Arg2,256);
  2485.  
  2486.     if(!StrCmp(Arg1,"SAVE"))
  2487.     {
  2488.         if(Arg2[0])
  2489.         {
  2490.             if(WriteIFFData(Arg2,MacroKeys,sizeof(struct MacroKeys),'KEYS'))
  2491.                 strcpy(LastMacros,Arg2);
  2492.             else
  2493.                 RexxRes1 = RC_ERROR;
  2494.         }
  2495.     }
  2496.  
  2497.     if(!StrCmp(Arg1,"LOAD"))
  2498.     {
  2499.         if(Arg2[0])
  2500.         {
  2501.             if(LoadMacros(Arg2,MacroKeys))
  2502.                 strcpy(LastMacros,Arg2);
  2503.             else
  2504.                 RexxRes1 = RC_ERROR;
  2505.         }
  2506.     }
  2507.  
  2508.     return(NULL);
  2509. }
  2510.  
  2511. UBYTE *
  2512. RexxConfig(UBYTE *String)
  2513. {
  2514.     UBYTE Arg1[40],Arg2[256];
  2515.     LONG ArgCount;
  2516.  
  2517.     Arg1[0] = Arg2[0] = 0;
  2518.     ArgCount = 0;
  2519.  
  2520.     GetToken(String,&ArgCount,Arg1,40);
  2521.     GetToken(String,&ArgCount,Arg2,256);
  2522.  
  2523.     if(!StrCmp(Arg1,"SAVE"))
  2524.     {
  2525.         if(Arg2[0])
  2526.         {
  2527.             if(WriteIFFData(Arg2,&Config,sizeof(struct Configuration),'PREF'))
  2528.                 strcpy(LastConfig,Arg2);
  2529.             else
  2530.                 RexxRes1 = RC_ERROR;
  2531.         }
  2532.     }
  2533.  
  2534.     if(!StrCmp(Arg1,"LOAD"))
  2535.     {
  2536.         if(Arg2[0])
  2537.         {
  2538.             struct Configuration PrivateConfig;
  2539.  
  2540.             if(ReadIFFData(Arg2,&PrivateConfig,sizeof(struct Configuration),'PREF'))
  2541.             {
  2542.                 Config = PrivateConfig;
  2543.  
  2544.                 ConfigSetup();
  2545.  
  2546.                 strcpy(LastConfig,Arg2);
  2547.             }
  2548.             else
  2549.                 RexxRes1 = RC_ERROR;
  2550.         }
  2551.     }
  2552.  
  2553.     return(NULL);
  2554. }
  2555.  
  2556. UBYTE *
  2557. RexxPhone(UBYTE *String)
  2558. {
  2559.     UBYTE Arg1[40],Arg2[256];
  2560.     LONG ArgCount;
  2561.  
  2562.     Arg1[0] = Arg2[0] = 0;
  2563.     ArgCount = 0;
  2564.  
  2565.     GetToken(String,&ArgCount,Arg1,40);
  2566.     GetToken(String,&ArgCount,Arg2,256);
  2567.  
  2568.     if(!StrCmp(Arg1,"SAVE"))
  2569.     {
  2570.         if(Arg2[0])
  2571.         {
  2572.             if(SavePhonebook(Arg2))
  2573.                 strcpy(LastPhone,Arg2);
  2574.             else
  2575.                 RexxRes1 = RC_ERROR;
  2576.         }
  2577.     }
  2578.  
  2579.     if(!StrCmp(Arg1,"LOAD"))
  2580.     {
  2581.         if(Arg2[0])
  2582.         {
  2583.             if(LoadPhonebook(Arg2))
  2584.                 strcpy(LastPhone,Arg2);
  2585.             else
  2586.                 RexxRes1 = RC_ERROR;
  2587.         }
  2588.     }
  2589.  
  2590.     return(NULL);
  2591. }
  2592.  
  2593. UBYTE *
  2594. RexxCapture(UBYTE *String)
  2595. {
  2596.     UBYTE Arg1[40],Arg2[256];
  2597.     LONG ArgCount;
  2598.  
  2599.     Arg1[0] = Arg2[0] = 0;
  2600.     ArgCount = 0;
  2601.  
  2602.     GetToken(String,&ArgCount,Arg1,40);
  2603.     GetToken(String,&ArgCount,Arg2,256);
  2604.  
  2605.     if(!StrCmp(Arg1,"CLOSE") && FileCapture)
  2606.     {
  2607.         struct MenuItem *SomeItem;
  2608.  
  2609.         SomeItem = FindThisItem(MEN_CAPTUREDISK);
  2610.  
  2611.         Close(FileCapture);
  2612.  
  2613.         SomeItem -> Flags &= ~CHECKED;
  2614.  
  2615.         FileCapture = NULL;
  2616.  
  2617.         if(!GetFileSize(CaptureName))
  2618.             DeleteFile(CaptureName);
  2619.     }
  2620.     else
  2621.     {
  2622.         if(!StrCmp(Arg1,"NEW") && Arg2[0])
  2623.             FileCapture = Open(Arg2,MODE_NEWFILE);
  2624.         else
  2625.         {
  2626.             if(!StrCmp(Arg1,"APPEND") && Arg2[0])
  2627.             {
  2628.                 if(FileCapture = Open(Arg2,MODE_READWRITE))
  2629.                 {
  2630.                     if(Seek(FileCapture,0,OFFSET_END) == -1)
  2631.                     {
  2632.                         Close(FileCapture);
  2633.  
  2634.                         FileCapture = NULL;
  2635.                     }
  2636.                 }
  2637.             }
  2638.         }
  2639.  
  2640.         if(FileCapture)
  2641.         {
  2642.             struct MenuItem *SomeItem;
  2643.  
  2644.             strcpy(CaptureName,Arg2);
  2645.  
  2646.             SomeItem = FindThisItem(MEN_CAPTUREDISK);
  2647.  
  2648.             SomeItem -> Flags |= CHECKED;
  2649.         }
  2650.         else
  2651.             RexxRes1 = RC_ERROR;
  2652.     }
  2653.  
  2654.     return(NULL);
  2655. }
  2656.  
  2657. UBYTE *
  2658. RexxBuffer(UBYTE *String)
  2659. {
  2660.     UBYTE Arg1[40],Arg2[256];
  2661.     LONG ArgCount;
  2662.  
  2663.     Arg1[0] = Arg2[0] = 0;
  2664.     ArgCount = 0;
  2665.  
  2666.     GetToken(String,&ArgCount,Arg1,40);
  2667.     GetToken(String,&ArgCount,Arg2,256);
  2668.  
  2669.     if(!StrCmp(Arg1,"NEW") || !StrCmp(Arg1,"APPEND"))
  2670.     {
  2671.         if(GetFileSize(Arg2))
  2672.         {
  2673.             BPTR SomeFile;
  2674.  
  2675.             if(SomeFile = Open(Arg2,MODE_OLDFILE))
  2676.             {
  2677.                 if(Lines)
  2678.                 {
  2679.                     if(!StrCmp(Arg1,"NEW"))
  2680.                         ClearBuffer();
  2681.                 }
  2682.  
  2683.                 LineRead(NULL,NULL,NULL);
  2684.  
  2685.                 while(LineRead(SomeFile,Arg2,80))
  2686.                     StoreBuffer(Arg2,strlen(Arg2));
  2687.  
  2688.                 Close(SomeFile);
  2689.             }
  2690.             else
  2691.                 RexxRes1 = RC_ERROR;
  2692.         }
  2693.         else
  2694.             RexxRes1 = RC_ERROR;
  2695.     }
  2696.     else
  2697.     {
  2698.         if(!StrCmp(Arg1,"DISPLAY"))
  2699.         {
  2700.             if(BufferProcess)
  2701.                 Signal(BufferProcess,SIGBREAKF_CTRL_D);
  2702.             else
  2703.             {
  2704.                 if(BufferProcess = (struct Process *)CreateNewProcTags(
  2705.                     NP_Entry,    BufferServer,
  2706.                     NP_Name,    "term Buffer Process",
  2707.                     NP_Priority,    0,
  2708.                     NP_StackSize,    8192,
  2709.                     NP_WindowPtr,    -1,
  2710.                 TAG_END))
  2711.                     Wait(SIGBREAKF_CTRL_C);
  2712.             }
  2713.         }
  2714.     }
  2715.  
  2716.     return(NULL);
  2717. }
  2718.  
  2719. UBYTE *
  2720. RexxFirstDownload()
  2721. {
  2722.     ObtainSemaphore(DownloadSemaphore);
  2723.  
  2724.     if(DownloadLineCount)
  2725.     {
  2726.         DownloadNode = DownloadList . lh_Head;
  2727.  
  2728.         if(DownloadNode -> ln_Succ)
  2729.         {
  2730.             strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  2731.  
  2732.             ReleaseSemaphore(DownloadSemaphore);
  2733.  
  2734.             return(RexxTextBuffer);
  2735.         }
  2736.     }
  2737.  
  2738.     ReleaseSemaphore(DownloadSemaphore);
  2739.  
  2740.     return("");
  2741. }
  2742.  
  2743. UBYTE *
  2744. RexxNextDownload()
  2745. {
  2746.     ObtainSemaphore(DownloadSemaphore);
  2747.  
  2748.     if(!DownloadNode)
  2749.         DownloadNode = DownloadList . lh_Head;
  2750.     else
  2751.         DownloadNode = DownloadNode -> ln_Succ;
  2752.  
  2753.     if(DownloadNode -> ln_Succ)
  2754.     {
  2755.         strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  2756.  
  2757.         ReleaseSemaphore(DownloadSemaphore);
  2758.  
  2759.         return(RexxTextBuffer);
  2760.     }
  2761.     else
  2762.         DownloadNode = NULL;
  2763.  
  2764.     ReleaseSemaphore(DownloadSemaphore);
  2765.  
  2766.     return("");
  2767. }
  2768.  
  2769. UBYTE *
  2770. RexxLastDownload()
  2771. {
  2772.     ObtainSemaphore(DownloadSemaphore);
  2773.  
  2774.     if(DownloadLineCount)
  2775.     {
  2776.         DownloadNode = DownloadList . lh_TailPred;
  2777.  
  2778.         strcpy(RexxTextBuffer,DownloadNode -> ln_Name);
  2779.  
  2780.         ReleaseSemaphore(DownloadSemaphore);
  2781.  
  2782.         return(RexxTextBuffer);
  2783.     }
  2784.  
  2785.     ReleaseSemaphore(DownloadSemaphore);
  2786.  
  2787.     return("");
  2788. }
  2789.  
  2790. UBYTE *
  2791. RexxWaitString(UBYTE *String)
  2792. {
  2793.     UBYTE         Arg1[40];
  2794.     LONG         ArgCount;
  2795.  
  2796.     struct ScanNode    *Matching = NULL;
  2797.  
  2798.     ULONG         SignalSet;
  2799.     SHORT         i;
  2800.  
  2801.     ULONG         Timeout = RexxGlobalTimeout;
  2802.  
  2803.     if(ReadPort)
  2804.     {
  2805.         Arg1[0] = 0;
  2806.  
  2807.         ArgCount = 0;
  2808.  
  2809.             /* Parse the argument looking for sequences
  2810.              * to wait for.
  2811.              */
  2812.  
  2813.         while(GetToken(String,&ArgCount,Arg1,40))
  2814.             AddSequenceObject(Arg1);
  2815.  
  2816.             /* If no timeout is set this routine becomes
  2817.              * a real trap: suppose the string to wait for
  2818.              * never happens to arrive -> we'll wait
  2819.              * forever. For this reason the default timeout
  2820.              * is set to five seconds.
  2821.              */
  2822.  
  2823.         if(Timeout < 1)
  2824.             Timeout = 5 * MILLION;
  2825.  
  2826.         TimeRequest -> tr_node . io_Command    = TR_ADDREQUEST;
  2827.         TimeRequest -> tr_time . tv_secs    = Timeout >= MILLION ? Timeout / MILLION : 0;
  2828.         TimeRequest -> tr_time . tv_micro    = Timeout % MILLION;
  2829.  
  2830.         SetSignal(0,SIG_TIMER);
  2831.  
  2832.         SendIO(TimeRequest);
  2833.  
  2834.         FOREVER
  2835.         {
  2836.             SignalSet = Wait(SIG_TIMER | SIG_SERIAL | SIGBREAKF_CTRL_D);
  2837.  
  2838.                 /* We are to abort the job. */
  2839.  
  2840.             if(SignalSet & SIGBREAKF_CTRL_D)
  2841.             {
  2842.                 Matching = NULL;
  2843.                 break;
  2844.             }
  2845.  
  2846.                 /* Serial data came in... */
  2847.  
  2848.             if(SignalSet & SIG_SERIAL)
  2849.             {
  2850.                 if(Status == STATUS_HOLDING)
  2851.                     Status = STATUS_READY;
  2852.  
  2853.                 /* Any news? */
  2854.  
  2855.                 if(CheckIO(ReadRequest))
  2856.                 {
  2857.                     LONG Length;
  2858.  
  2859.                     if(!WaitIO(ReadRequest))
  2860.                     {
  2861.                         /* Send the byte to the console. */
  2862.  
  2863.                         ConProcess(ReadBuffer,1);
  2864.  
  2865.                         if(Matching == NULL)
  2866.                             Matching = SequenceFilter(((UBYTE *)ReadBuffer)[0]);
  2867.  
  2868.                         /* Loop until all data has been processed. */
  2869.  
  2870. Loop:                        do
  2871.                         {
  2872.                             /* Check how many bytes are still in
  2873.                              * the serial buffer.
  2874.                              */
  2875.  
  2876.                             WriteRequest -> IOSer . io_Command = SDCMD_QUERY;
  2877.                             DoIO(WriteRequest);
  2878.  
  2879.                             if(Length = WriteRequest -> IOSer . io_Actual)
  2880.                             {
  2881.                                 if(Length > 1024)
  2882.                                     Length = 1024;
  2883.  
  2884.                                 ReadRequest -> IOSer . io_Command    = CMD_READ;
  2885.                                 ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2886.                                 ReadRequest -> IOSer . io_Length    = Length;
  2887.  
  2888.                                 DoIO(ReadRequest);
  2889.  
  2890.                                 /* Send the data to the console. */
  2891.  
  2892.                                 ConProcess(ReadBuffer,Length);
  2893.  
  2894.                                 if(Matching == NULL)
  2895.                                 {
  2896.                                     for(i = 0 ; i < Length ; i++)
  2897.                                     {
  2898.                                         if(Matching = SequenceFilter(((UBYTE *)ReadBuffer)[i]))
  2899.                                             break;
  2900.                                     }
  2901.                                 }
  2902.                             }
  2903.                         }
  2904.                         while(Length);
  2905.  
  2906.                         /* Ask for another byte. */
  2907.  
  2908.                         ReadRequest -> IOSer . io_Command    = CMD_READ;
  2909.                         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  2910.                         ReadRequest -> IOSer . io_Length     = 1;
  2911.  
  2912.                         SendIO(ReadRequest);
  2913.                     }
  2914.                 }
  2915.             }
  2916.  
  2917.                 /* Timeout has occured. */
  2918.  
  2919.             if(SignalSet & SIG_TIMER)
  2920.                 break;
  2921.  
  2922.                 /* We've made a match! */
  2923.  
  2924.             if(Matching)
  2925.                 break;
  2926.         }
  2927.  
  2928.             /* Is the timer still active? If so, cancel it. */
  2929.  
  2930.         if(!CheckIO(TimeRequest))
  2931.             AbortIO(TimeRequest);
  2932.  
  2933.             /* Wait for timer to return. */
  2934.  
  2935.         WaitIO(TimeRequest);
  2936.  
  2937.             /* Determine the result code if a match has been
  2938.              * made.
  2939.              */
  2940.  
  2941.         if(Matching)
  2942.             strcpy(RexxTextBuffer,Matching -> Sequence);
  2943.         else
  2944.             RexxTextBuffer[0] = 0;
  2945.     }
  2946.  
  2947.         /* Clear the list of sequences to check. */
  2948.  
  2949.     ClearSequenceObjects();
  2950.  
  2951.     return(RexxTextBuffer);
  2952. }
  2953.  
  2954. UBYTE *
  2955. RexxToneDial(UBYTE *String)
  2956. {
  2957.     if(ToneDial(String))
  2958.         DeleteTone();
  2959.     else
  2960.         RexxRes1 = RC_ERROR;
  2961.  
  2962.     return(NULL);
  2963. }
  2964.  
  2965. VOID
  2966. Rexx2Front()
  2967. {
  2968.     if(RexxWindow)
  2969.         BumpWindow(RexxWindow);
  2970. }
  2971.  
  2972. VOID
  2973. Term2Front()
  2974. {
  2975.     BumpWindow(Window);
  2976. }
  2977.  
  2978. VOID
  2979. Display2Front()
  2980. {
  2981.     if(BufferProcess)
  2982.         Signal(BufferProcess,SIGBREAKF_CTRL_D);
  2983. }
  2984.  
  2985. VOID
  2986. CloseDisplay()
  2987. {
  2988.     if(BufferProcess)
  2989.         Signal(BufferProcess,SIGBREAKF_CTRL_C);
  2990. }
  2991.  
  2992. VOID
  2993. QuietExit()
  2994. {
  2995.     ExitQuietly = TRUE;
  2996. }
  2997.  
  2998.     /* RexxASyncCommand(struct RexxMsg *RexxMsg):
  2999.      *
  3000.      *    This routine handles the asynchronous Rexx
  3001.      *    commands and complains if the command passed
  3002.      *    to it cannot be executed asynchronously.
  3003.      */
  3004.  
  3005. BYTE
  3006. RexxASyncCommand(struct RexxMsg *RexxMsg,UBYTE *Arg1,UBYTE *Arg2)
  3007. {
  3008.     LONG    ArgCount = 0;
  3009.     STRPTR    StringResult = NULL;
  3010.     SHORT    i;
  3011.     LONG    RexxRes1 = RC_OK;
  3012.  
  3013.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3014.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3015.  
  3016.     if(!StrCmp(Arg1,"QUERY"))
  3017.     {
  3018.         if(!StrCmp(Arg2,"COLOUR"))
  3019.         {
  3020.             LONG Colour;
  3021.  
  3022.             GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3023.  
  3024.             Colour = atol(Arg1);
  3025.  
  3026.             if(Colour >= 0 && Colour < (1 << (Config . ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth)))
  3027.             {
  3028.                 SPrintf(RexxTextBuffer,"%03lx",Config . Colours[Colour]);
  3029.  
  3030.                 StringResult = RexxTextBuffer;
  3031.             }
  3032.             else
  3033.                 RexxRes1 = RC_ERROR;
  3034.         }
  3035.         else
  3036.         {
  3037.             if(!StrCmp(Arg2,"MACRO"))
  3038.             {
  3039.                 LONG Value,Qualifier = -1;
  3040.  
  3041.                 GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3042.  
  3043.                 for(i = 0 ; i < 4 ; i++)
  3044.                 {
  3045.                     if(!StrCmp(Qualifiers[i],Arg2))
  3046.                     {
  3047.                         Qualifier = i;
  3048.                         break;
  3049.                     }
  3050.                 }
  3051.  
  3052.                 if(Qualifier != -1)
  3053.                 {
  3054.                     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3055.  
  3056.                     Value = atol(Arg2);
  3057.  
  3058.                     if(Value >= 0 && Value <= 9)
  3059.                         StringResult = MacroKeys -> Keys[Qualifier][Value];
  3060.                     else
  3061.                         RexxRes1 = RC_ERROR;
  3062.                 }
  3063.                 else
  3064.                     RexxRes1 = RC_ERROR;
  3065.             }
  3066.             else
  3067.             {
  3068.                 for(i = 0 ; i < NUMQUERIES ; i++)
  3069.                 {
  3070.                     if(!StrCmp(Arg2,QueryCommands[i] . String))
  3071.                         StringResult = QueryCommands[i] . Routine();
  3072.                 }
  3073.             }
  3074.         }
  3075.     }
  3076.     else
  3077.     {
  3078.         for(i = 0 ; i < NUMASYNCS ; i++)
  3079.         {
  3080.             if(!StrCmp(Arg1,ASyncCommands[i] . String))
  3081.             {
  3082.                 ASyncCommands[i] . Routine();
  3083.  
  3084.                 i = -1;
  3085.  
  3086.                 break;
  3087.             }
  3088.         }
  3089.  
  3090.         if(i != -1)
  3091.             return(FALSE);
  3092.     }
  3093.  
  3094.     ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3095.  
  3096.     return(TRUE);
  3097. }
  3098.  
  3099.     /* RexxSyncCommand(struct RexxMsg *RexxMsg):
  3100.      *
  3101.      *    Handles the synchronous Rexx commands and returns the
  3102.      *    message if no matching command is found.
  3103.      */
  3104.  
  3105. VOID
  3106. RexxSyncCommand(struct RexxMsg *RexxMsg,UBYTE *Arg1,UBYTE *Arg2)
  3107. {
  3108.     LONG    ArgCount = 0,Count2;
  3109.     STRPTR    StringResult = NULL;
  3110.     SHORT    i;
  3111.  
  3112.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg1,80);
  3113.  
  3114.         /* Save position of second argument for the
  3115.          * Rexx commands.
  3116.          */
  3117.  
  3118.     Count2 = ArgCount;
  3119.  
  3120.     GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3121.  
  3122.     RexxRes1 = RC_OK;
  3123.  
  3124.         /* Look if it's a `set' command. */
  3125.  
  3126.     if(!StrCmp(Arg1,"SET"))
  3127.     {
  3128.         for(i = 0 ; i < SETMOREPARAMS ; i++)
  3129.         {
  3130.             if(!StrCmp(Arg2,SetCommands[i] . String))
  3131.             {
  3132.                 SetCommands[i] . Routine(&RexxMsg -> rm_Args[0][ArgCount]);
  3133.  
  3134.                 ReplyRexxCommand(RexxMsg,RexxRes1,0,NULL);
  3135.  
  3136.                 return;
  3137.             }
  3138.         }
  3139.  
  3140.         for(i = SETMOREPARAMS ; i < NUMSETS ; i++)
  3141.         {
  3142.             if(!StrCmp(Arg2,SetCommands[i] . String))
  3143.             {
  3144.                 GetToken(RexxMsg -> rm_Args[0],&ArgCount,Arg2,80);
  3145.  
  3146.                 SetCommands[i] . Routine(Arg2);
  3147.  
  3148.                 ReplyRexxCommand(RexxMsg,RexxRes1,0,NULL);
  3149.  
  3150.                 return;
  3151.             }
  3152.         }
  3153.     }
  3154.  
  3155.     for(i = 0 ; i < REXXMOREPARAMS ; i++)
  3156.     {
  3157.         if(!StrCmp(Arg1,RexxCommands[i] . String))
  3158.         {
  3159.             StringResult = RexxCommands[i] . Routine(&RexxMsg -> rm_Args[0][Count2]);
  3160.  
  3161.             ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3162.  
  3163.             return;
  3164.         }
  3165.     }
  3166.  
  3167.     for(i = REXXMOREPARAMS ; i < NUMREXX ; i++)
  3168.     {
  3169.         if(!StrCmp(Arg1,RexxCommands[i] . String))
  3170.         {
  3171.             StringResult = RexxCommands[i] . Routine(Arg2);
  3172.  
  3173.             ReplyRexxCommand(RexxMsg,RexxRes1,0,StringResult);
  3174.  
  3175.             return;
  3176.         }
  3177.     }
  3178.  
  3179.     ReplyRexxCommand(RexxMsg,RC_ERROR,0,NULL);
  3180. }
  3181.  
  3182.     /* RexxServer(VOID):
  3183.      *
  3184.      *    Asynchronous ARexx host server.
  3185.      */
  3186.  
  3187. VOID __saveds
  3188. RexxServer(VOID)
  3189. {
  3190.     UBYTE         Arg1[80],Arg2[80];
  3191.  
  3192.     struct MsgPort    *RexxPort;
  3193.     struct RexxMsg    *RexxMsg;
  3194.  
  3195.     ULONG         SignalSet;
  3196.  
  3197.     BYTE         Terminated = FALSE;
  3198.  
  3199.         /* Create the public host port. */
  3200.  
  3201.     if(RexxPort = (struct MsgPort *)CreateMsgPort())
  3202.     {
  3203.         RexxPort -> mp_Node . ln_Name    = TermIDString;
  3204.         RexxPort -> mp_Node . ln_Pri    = 1;
  3205.  
  3206.             /* Make it a public port. */
  3207.  
  3208.         AddPort(RexxPort);
  3209.  
  3210.             /* Signal our father that we're running. */
  3211.  
  3212.         Signal(ThisProcess,SIGBREAKF_CTRL_C);
  3213.  
  3214.             /* Go into loop and wait for input. */
  3215.  
  3216.         while(!Terminated)
  3217.         {
  3218.             SignalSet = Wait(SIGBREAKF_CTRL_C | (1 << RexxPort -> mp_SigBit));
  3219.  
  3220.                 /* This is probably a Rexx command. */
  3221.  
  3222.             if(SignalSet & (1 << RexxPort -> mp_SigBit))
  3223.             {
  3224.                     /* Pick up all the messages. */
  3225.  
  3226.                 while(RexxMsg = (struct RexxMsg *)GetMsg(RexxPort))
  3227.                 {
  3228.                     Arg1[0] = Arg2[0] = 0;
  3229.  
  3230.                         /* At first try to run the
  3231.                          * command asynchronously.
  3232.                          * If this turns out to be
  3233.                          * somewhat `impossible' pass
  3234.                          * it to the `term' main process
  3235.                          * or - if in batch mode - try
  3236.                          * to deal with the message
  3237.                          * on our own.
  3238.                          */
  3239.  
  3240.                     if(!RexxASyncCommand(RexxMsg,Arg1,Arg2))
  3241.                     {
  3242.                         if(!BatchMode)
  3243.                             PutMsg(TermRexxPort,RexxMsg);
  3244.                         else
  3245.                             ReplyRexxCommand(RexxMsg,-1,0,NULL);
  3246.                     }
  3247.                 }
  3248.             }
  3249.  
  3250.             if(SignalSet & SIGBREAKF_CTRL_C)
  3251.                 Terminated = TRUE;
  3252.         }
  3253.  
  3254.         Forbid();
  3255.  
  3256.         while(RexxMsg = (struct RexxMsg *)GetMsg(RexxPort))
  3257.             ReplyRexxCommand(RexxMsg,-1,0,NULL);
  3258.  
  3259.         RemPort(RexxPort);
  3260.  
  3261.         DeleteMsgPort(RexxPort);
  3262.     }
  3263.  
  3264.     Forbid();
  3265.  
  3266.     RexxProcess = NULL;
  3267.  
  3268.     Signal(ThisProcess,SIGBREAKF_CTRL_C);
  3269. }
  3270.  
  3271.     /* HandleRexx():
  3272.      *
  3273.      *    Tiny & simple subroutine to read and examine all
  3274.      *    messages coming in to be processed synchronously
  3275.      *    by the `term' main process.
  3276.      */
  3277.  
  3278. VOID
  3279. HandleRexx()
  3280. {
  3281.     struct RexxMsg    *RexxMsg;
  3282.     UBYTE         Arg1[80],Arg2[256];
  3283.  
  3284.     while(RexxMsg = (struct RexxMsg *)GetMsg(TermRexxPort))
  3285.     {
  3286.         Arg1[0] = Arg2[0] = 0;
  3287.  
  3288.         RexxSyncCommand(RexxMsg,Arg1,Arg2);
  3289.     }
  3290. }
  3291.